This is a python program to remove punctuation from a string (tested in version 3.4)
Output:
Enter a string: "Hello!!!", Good Morning --- Have a good day.
Hello Good Morning Have a good day
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # Program to all punctuations from the # string provided by the user # define punctuations punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' # take input from the user my_str = input("Enter a string: ") # remove punctuations 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:
Enter a string: "Hello!!!", Good Morning --- Have a good day.
Hello Good Morning Have a good day
Comments
Post a Comment