Created
July 19, 2020 12:39
-
-
Save raeq/5ef457c954f0a6af3cf11c4e9ac35024 to your computer and use it in GitHub Desktop.
Remove punctuation from a string
This file contains hidden or 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
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