Created
May 31, 2017 19:42
-
-
Save tyler-austin/494cc8fb2ebb15b1cca1558d7534622c to your computer and use it in GitHub Desktop.
strip unwanted punctuation
This file contains 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
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