+ 1

How to find highest number in list?

My list having integer and string but I need to find highest number by excluding string Should I try statement? Is there any other way https://code.sololearn.com/crt6oPCffBLs/?ref=app

24th Jan 2019, 4:17 AM
Raj Charan
3 ответов
+ 4
lst=['1','3','002','0000','x','chef'] print(max([int(n) for n in lst if n.isnumeric()])) Don't use "list" as a name for a list! 😤
24th Jan 2019, 6:37 AM
Anna
Anna - avatar
+ 3
Nice. One line is all it takes, this shows how expressive the language can be.
24th Jan 2019, 8:59 AM
Zen
Zen - avatar
+ 1
Thank you Anna
28th Jan 2019, 2:09 AM
Raj Charan