Write a Python Program to Remove Punctuations From a String

Python Program to Remove Punctuations From a String

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn  Python programming concepts. You can learn Python language at your own speed and time. One can learn concepts of Python language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

ython Program to Remove Punctuations From a String
Python Program to Remove Punctuations From a String

Write a Python Program to Remove Punctuations From a String

PROGRAM: Python Program to Remove Punctuations From a String

/* Python Program to Remove Punctuations From a String */

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

my_str = “Hello!!!, he said —and went.”

# To 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 punctuations:
no_punct = no_punct + char

# display the unpunctuated string
print(no_punct)

OUTPUT :-

Hello he said and went

Leave a Reply

Your email address will not be published. Required fields are marked *