Palindromes please help

hello guys take a look at these two labs below:
LAB 1.
text = input("Enter text: ")
text = text.replace(’ ‘,’’)
if len(text) > 1 and text.upper() == text[::-1].upper():
print(“It’s a palindrome”)
else:
print(“It’s not a palindrome”)

LAB 2
c = input (‘enter sms: ‘)
c = c.replace(’ ‘,’’)
c = c.lower()
d = list©
b =
for i in d:
b.insert(0,i)
e = ‘’.join(b)

if c == e:
print(“It’s a palindrome”)
else:
print(“It’s not a palindrome”)

So, I was given a task as follows:
Do you know what a palindrome is?

It’s a word which look the same when read forward and backward. For example, “kayak” is a palindrome, while “loyal” is not.

Your task is to write a program which:

asks the user for some text;
checks whether the entered text is a palindrome, and prints result.

Note:

assume that an empty string isn't a palindrome;
treat upper- and lower-case letters as equal;
spaces are not taken into account during the check - treat them as non-existent;

so lab 1 was the answer from the intructor and lab 2 was my solution.
so is my solution right too or I was wrong? please help

It’s a little hard to tell – you didn’t mark-up your code as code, so the forum appears to have “helpfully” translated some character sequences into symbols and lost all your indenting.

The acid test is trying it and seeing. Does it correctly identify easy palindromes like “abcba” and reject “abcda”? Does it reject an empty string? Does it regard single letters as palindromes? Does it cope with mixed case? Try a few palindromes and non-palindromes on both your program and your supervisor’s program. If both programs say the same thing, great. If not, try to figure out why.

(I think you fail one of the tests I mentioned above. Try it and see!)

1 Like