Last active
August 29, 2015 13:57
-
-
Save amundo/9613510 to your computer and use it in GitHub Desktop.
A simple depunctuator with and without regexes
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
def depunctuate(raw, badletters): | |
""" | |
return a copy of the string raw with all of | |
badletters removed | |
""" | |
fixed = '' | |
for letter in raw: | |
if letter not in badletters: | |
fixed += letter | |
return fixed | |
print depunctuate("""Does this work?? DOES IT?!? Tell me... I just -- I can't.""", """.'?!-""") | |
print depunctuate("""1, 2, 3, is this thing on?""", """0123456789,?""") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment