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?

WarpPrime
  • 215
  • 5
  • 20

1 Answers1

-1

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

Just for fun
  • 4,102
  • 1
  • 5
  • 11