How to extract all the numbers from a string into a list using list comprehension in Python

1 Answer

0 votes
s = "C++ 14 Python 3.7.3"

lst = [x for x in s if x.isdigit()]

print(lst)



'''
run:

['1', '4', '3', '7', '3']

'''

 



answered Aug 22, 2019 by avibootz
...