Skip to content

Instantly share code, notes, and snippets.

@raeq
Created July 19, 2020 12:39
Show Gist options
  • Save raeq/5ef457c954f0a6af3cf11c4e9ac35024 to your computer and use it in GitHub Desktop.
Save raeq/5ef457c954f0a6af3cf11c4e9ac35024 to your computer and use it in GitHub Desktop.
Remove punctuation from a string
import string
def remove_punctuation(input_string: str = "") -> str:
return input_string.translate(str.maketrans("", "", string.punctuation))
assert remove_punctuation("Hello!") == "Hello"
assert remove_punctuation("He. Saw! Me?") == "He Saw Me"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment