Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. input_string = "lol num 024, and 20942 when 4.4 points5 lo6lo"
  2.  
  3. found_numbers = []
  4. buffer_string = ''
  5. for char in input_string:
  6. if char.isdigit():
  7. if char != '0' or buffer_string:
  8. buffer_string += char
  9. else:
  10. if buffer_string:
  11. found_numbers.append(int(buffer_string))
  12. buffer_string = ''
  13.  
  14. print(found_numbers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement