I have a list of punctuation that I want the loop to remove from a user inputted sentence, and it seems to ignore multiple punctuation in a row?
punctuation = ['(', ')', '?', ':', ';', ',', '.', '!', '/', '"', "'"]
usr_str=input('Type in a line of text: ')
#Convert to list
usr_list= list(usr_str)
#Checks if each item in list is punctuation, and removes ones that are
for char in usr_list:
if char in punctuation:
usr_list.remove(char)
#Prints resulting string
print(''.join(usr_list))
Now this works for:
This is an example string, which works fine!
Which prints:
This is an example string which works fine
However, something like this:
Testing!!!!, )
Gives:
Testing!!
Thanks in advance for the help!