Home >>Python Programs >Remove Punctuation From a String in Python
In this example, we will see a Python program to remove punctuation marks from any given input string. Punctuation is the the practice, action, or system of inserting points or other small marks into the texts, in order to division of text into sentences, clauses, etc.
Example :
# define punctuation
punctuation = '''''!()-[]{};:'"\,<>./?@#$%^&*_~'''
# take input from the user
my_str = input("Enter a string: ")
# remove punctuation from the string
no_punct = ""
for char in my_str:
if char not in punctuation:
no_punct = no_punct + char
# display the unpunctuated string
print(no_punct)