In this program, we will take a string as input and remove punctuations from a string.
Steps to solve the program
- Take a string as input.
- Create an empty string and a string containing all the punctuations.
- Use for loop to iterate over every character from the input string.
- If the character is not in the list containing punctuations then add that character to the empty string.
- Print the output.
#Input string
string1 = "Sqatools : is best, for python"
string2 = ""
punc = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
for char in string1:
if char not in punc:
string2 += char
#Printing output
print(string2)
Output :
Sqatools is best for python