How to get the highest number in string with Python

1 Answer

0 votes
import re
   
s = 'a213python 34 java98 c++ 88397 php 3.14 swift 6-89x'
   
lst = re.findall('[0-9]+', s)

mx = max(int(n) for n in lst) 
   
print(mx)
     
     
     
'''
run:
     
88397
   
'''

 



answered Dec 17, 2020 by avibootz

Related questions

1 answer 165 views
1 answer 174 views
3 answers 224 views
1 answer 152 views
...