stefbrad15

Clean String Challenge

Apr 19th, 2022
1,342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. data = 'z342512b?333~h123>n<724BB400*a'
  2. temp_str = ""
  3. output = []
  4.  
  5. for char in data:
  6.     if char.isnumeric():
  7.         temp_str += char
  8.         if len(temp_str) == 3:
  9.             output.append(int(temp_str))
  10.             temp_str = ""
  11.  
  12. output.sort()
  13. print(output)
Advertisement
Add Comment
Please, Sign In to add comment