programming-examples/python/_Basics/Python Program to Remove Punctuations From a String.py

16 lines
385 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
# 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)