Remove Punctuations From a String in Python Using String
(Last Updated On: 12/01/2023)
Python Program to Remove Punctuations From a String Using String Package
# Python Program to Remove Punctuations From a String Using String Package
import string
sample_text = "Hello, Newtum !is# ^the*@ b)e$st^ platform>< to Learn P>ython??"
print("Input String: " + sample_text)
# logic to remove punctuations from a string
sample_text = sample_text.translate(str.maketrans('', '', string.punctuation))
print("Final String: " + sample_text)
Output:
Input String: Hello, Newtum !is# ^the*@ b)e$st^ platform>< to Learn P>ython??
Final String: Hello Newtum is the best platform to Learn Python