Skip to content

Instantly share code, notes, and snippets.

Created October 15, 2017 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/17eaf5506b15f357c976e4607ba97d7f to your computer and use it in GitHub Desktop.
Save anonymous/17eaf5506b15f357c976e4607ba97d7f to your computer and use it in GitHub Desktop.
def change_number(number):
#broken down
new_number = ''
for character in number:
if character.isdigit():
new_number += character
print(new_number)
#condensed
new_number = ''.join([str(character) for character in number if character.isdigit()])
print(new_number)
change_number('123,abc,123')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment