How to sum all numbers from a string in Python

1 Answer

0 votes
import re

s = "1py34 thon70"

print(sum(map(int, re.findall("\d+", s))))



'''
run:

15

'''

 



answered May 27, 2019 by avibootz
...