Python Program to remove punctuation mark from the string

In this simple python program, we need to remove the punctuation mark from the string. It's a beginner-level python program.

To understand this example, you should have knowledge of the following Python programming topics:

What is a punctuation mark?

The punctuation mark is a practice to insert some special symbols into a string or sentence to make it more meaningful and look good. In this string python program, we have to remove all the punctuation marks from the string or a sentence. The punctuation mark is used to get the proper impact of the string.

How will the punctuation mark be removed in python?

For example "Don't go outside," she said. In this basic python program, we need to remove the punctuation marks, and then the string will be 'Don't go outside she said.

In this python program example, here we define punctuation as the 24 symbols we use in the string. Now we accept a string from the user in python and store it in a variable, and we use a python for loop to traverse till the end of the string. Use an if condition to check if it is not punctuation; if so, we add the character to the variable and print that variable.


STEP 1: Define the punctuation marks using the variable.

STEP 2: Accept input from the user using the input function in the python programming language.

STEP 3: Initialize a no-punct variable.

STEP 4: Use a for loop to traverse through the string.

STEP 5: Use an if condition to check for a character and add the character to the no-punct variable using python language.

STEP 6: Print the no-punct string.

Python Source Code

                                          punctuation = '''''!()-[]{};:'"\,<>./?@#$%^&*_~'''  

str = input("Enter a string: ") 
no_punct = ""  

for char in str:  

   if char not in punctuation:  

       no_punct = no_punct + char  



Enter the string : "Don't go outside," she said.

Dont go outside she said