Skip to content

Instantly share code, notes, and snippets.

@amundo
Last active August 29, 2015 13:57
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 amundo/9613510 to your computer and use it in GitHub Desktop.
Save amundo/9613510 to your computer and use it in GitHub Desktop.
A simple depunctuator with and without regexes
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