Skip to content

Instantly share code, notes, and snippets.

@jonathanagustin
Last active April 29, 2020 09:57
Show Gist options
  • Select an option

  • Save jonathanagustin/fc08a48f535b1d856a33b229c39670b0 to your computer and use it in GitHub Desktop.

Select an option

Save jonathanagustin/fc08a48f535b1d856a33b229c39670b0 to your computer and use it in GitHub Desktop.
Clean way of removing punctuation from a string
import string
# make table for translate() to remove punctuation
table = str.maketrans('', '', string.punctuation)
my_string = "!!!asdf"
new_string = my_string.translate(table)
print(new_string)
# prints asdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment