I found two other posts asking about this error on stack overflow but the answers weren't very helpful in providing relevant solutions. I've just started learning python and am trying to make a palindrome tester but I want it to remove all punctuation from the input. I keep getting the error in the title and I don't know how to fix it. Here is my code:
while 1:
def reverse(text):
return text[::-1]
def eliminate_punc(para):
para = para[:]
forbidden = ('.','?','!',':',';','-','—-','()','[]','...',"'",'"','/',',',' ')
for item in para:
for sign in forbidden:
if item == sign:
para.remove(item)
return para
def is_palindrome(words):
text = eliminate_punc(words)
return text == reverse(text)
user_input = input("Enter text: ")
if user_input == "quit":
break
if is_palindrome(user_input):
print("\nYes, this is a palindrome")
else:
print("\nNo, this is not a palindrome")
print("\nWrite 'quit' to quit the program\n")
Please help. Thanks in advance.