700
In this article we show how to remove punctuation marks from a string in python
There are 14 punctuation marks that are used in the English language.
They are: the period, question mark, exclamation point, comma, semicolon, colon, hyphen, dash, braces, brackets, parentheses, apostrophe, quotation mark, and ellipsis.
Example
# Remove Punctuation in a String punctuations = '''`~!@#$%^&*()-_=+{}[]\|;:'",.<>?''' myString = "This is, a test-string (full) of punctuations ! [ok]?" newString = "" for char in myString: if char not in punctuations: newString = newString + char print("\nThe Original String") print(myString) print("\nThe Final String") print(newString)
When you run this you will see something like this
>>> %Run removepunctuations.py The Original String This is, a test-string (full) of punctuations ! [ok]? The Final String This is a teststring full of punctuations ok