Created
August 28, 2017 12:52
-
-
Save komuw/cdb18fedc803dff1ffafab30ce495c90 to your computer and use it in GitHub Desktop.
extract numbers from string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| str = "h3110 23 cat 444.4 rabbit 11 2 dog" | |
| numbers = [int(s) for s in str.split() if s.isdigit()] | |
| sum_of_numbers = sum(numbers) | |
| print "sum_of_numbers:", sum_of_numbers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment