How to print the numbers from a string in Python

1 Answer

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

'''

 



answered Oct 27, 2020 by avibootz

Related questions

1 answer 137 views
1 answer 173 views
1 answer 129 views
1 answer 202 views
...