1

For example, I have a list a = ['3*4', '2*3', '4*6'],

I want to print the string in the list whose result will be the largest, '4*6' in this case.

wong2
  • 34,358
  • 48
  • 134
  • 179

1 Answers1

7
>>> a = ['3*4', '2*3', '4*6']
>>> max(a, key=eval)
'4*6'

with the usual caveats about using eval of course

Community
  • 1
  • 1
John La Rooy
  • 295,403
  • 53
  • 369
  • 502