Write a program to Remove Punctuations From a String in Python
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # define punctuation punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' # 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) |