0

I have some math expressions in a list, like ["2", "*", "2"], ["3", "+", "pi"]. Now, I want the list elements that contain ONLY digits to be detected, and be converted to integers. Is there a way to do this?

fasterthanlight
  • 205
  • 3
  • 18

1 Answers1

-1

newList = [int(i) for i in oldList if i.isdigit()]

Just for fun
  • 3,914
  • 1
  • 3
  • 10