You are given a string, write a program to find whether the string is palindrome or not.
Note: Treat uppercase letters and lowercase letters as same when comparing letters. Ignore spaces and quotes within the string.
The first line of input is a string.
The output should be
In the given example, the string
No lemon no melon is a palindrome as we are ignoring spaces. So, the output should be True.
Was it a cat I saw? so the output should be False
source = input()
letters = ''
for ch in source:
if ch != '"' and ch.isspace() == False:
letters += ch.lower()
reversed=letters[::-1]
print(letters == reversed)
Comments
Leave a comment