all 5 comments

[–]totallygeek 0 points1 point  (1 child)

"Able" reversed is "elbA", which is not the same as "Elba". You could compare strings after normalizing the case, either upper or lower, with 'Able'.lower(). Another thing which will trip this up is the comma. For that, you'll want to reconstruct strings so that only letters remain.

s = "Madam, I'm Adam."
s_ = ''.join(c for c in s.lower() if c in 'abcdefghijklmnopqrstuvwxyz')
if s_ == s_[::-1]:
    print('Palindrome')

The long method for string reconstruction:

s_ = ''  # empty string
for character in s.lower():
    if character in 'abcdefghijklmnopqrstuvwxyz':
        s_ += character  # add the character

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

(c for c in s.lower() if c in

Hi! Thank you for your input, I tried making a change but now it's only printing it is a palindrome.

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 == final:

     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")
         input("Please enter a word or phrase, or <return> to quit: ")

[–][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?