-3

so I am trying to extract the largest number from a list of strings in python. The string I'm trying to work with looks like this

a = ['a', '3', '5', 'c10', 'foo', 'bar', '999']

And I'm trying to get back the largest number. So in this case, it would be 999 and I wan't it back as an int.

I can't seem to find a pretty way of doing this, hope you guys can help.

Shadesfear
  • 749
  • 4
  • 17

1 Answers1

6
 max( [int(x) for x in a if x.isnumeric()])
LukasNeugebauer
  • 1,331
  • 7
  • 10