Skip to content

Instantly share code, notes, and snippets.

@tyler-austin
Created May 31, 2017 19:42
Show Gist options
  • Save tyler-austin/494cc8fb2ebb15b1cca1558d7534622c to your computer and use it in GitHub Desktop.
Save tyler-austin/494cc8fb2ebb15b1cca1558d7534622c to your computer and use it in GitHub Desktop.
strip unwanted punctuation
PUNCTUATION = '!"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~'
def remove_punctuation(in_string):
for punc in PUNCTUATION:
in_string = in_string.replace(punc, '')
return in_string
bad_string = 'I like (love) 2 make - life hard _ 4 my programmers #$AD!!!!'
bad_string = remove_punctuation(bad_string)
print(bad_string)
'''
>>> 'I like love 2 make life hard _ 4 my programmers AD'
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment