How to get the first number from a string in Python

1 Answer

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

 



answered Oct 27, 2020 by avibootz

Related questions

...