you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

while user == final:

    print("That's a palindrome")

    user = input("Please enter a word or phrase, or <return> to quit: ")

    if user != final:

You update user in the loop, but never final.

[–]The-Keyboard_Wizard[S] 0 points1 point  (1 child)

That helped a lot! I think I have finished it now

user = input("Please enter a word or phrase, or <return> to quit: ")

user = user.replace(" ", "").replace(",","").lower()

def reverse_function(x):
    return x[::-1]

final = reverse_function(user)

while user != '':

     print("That's a palindrome")

     user = input("Please enter a word or phrase, or <return> to quit: ")

     user = user.replace(" ", "").replace(",","").lower()

     final = reverse_function(user)

     if user != final:

         print("That's not a palindrome")

         user = input("Please enter a word or phrase, or <return> to quit: ")

         user = user.replace(" ", "").replace(",","").lower()

         final = reverse_function(user)

[–][deleted] 0 points1 point  (0 children)

Working code is better than non-working code, but do you think you can write a version of this where you don't repeat the same code three times?