Saturday, 23 December 2017

Python Program to Remove Punctuation from a String


Code:

# define punctuation  
punctuation = '''''!()-[]{};:'"\,<>./?@#$%^&*_~'''  
# 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 punctuation:  
       no_punct = no_punct + char  
# display the unpunctuated string  
print(no_punct)  


Output:

Execute and get the output.


More Python Programs:




Python Program to check if a Number is Positive, Negative or Zero
Python Program to Check if a Number is Odd or Even
Python Program to Check Leap Year
Python Program to Check Prime Number
Python Program to Print all Prime Numbers between an Interval
Python Program to Find the Factorial of a Number
Python Program to Display the multiplication Table
Python Program to Print the Fibonacci sequence
Python Program to Check Armstrong Number
Python Program to Find Armstrong Number between an Interval
Python Program to Find the Sum of Natural Numbers















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...