PROBLEM 4. Write a loop that creates a new word list, using a string method to strip the words from the list created in Problem 3 of all leading and trailing punctuation. Hint: the string library, which is imported above, contains a constant named punctuation. Three lines of code.
Okay, I have done the code as follows:
import string
text = ("There once was a man in Idaho, he invented the potato.")
listWords = text.split() #problem3
for i in string.punctuation:
listWords = text.replace(i,"") #problem4
This code works, but it only removes quotations. How do I remove other forms of punctuation?