• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
September 26, 2022 |2.3K Views

Python program to Remove Punctuation from String

  Share   Like
Description
Discussion

In this tutorial, we will write a Python program to remove punctuations from a given string.

Below is the list of approaches that we will cover in this section:

1. Remove punctuations from a given string using the loop.
2. Remove punctuations from a given string using the regex.

In the first method, we used a loop in which we list out all the special symbols in a list and we replaced all of them will blank using replace() function. 

In the second method, we used the regex using re.sub(r'[^\w\s]'. Here, we are selecting all the character except white spaces and Alpha-numerical character.

Python program to remove punctuation from string: https://www.geeksforgeeks.org/python-remove-punctuation-from-string/