ASSIGNMENT - 11
You are given a string, write a program to find whether the string is palindrome or not.
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.
Sample Input 1
No lemon no melon
Sample Output 1
True
Sample Input 2
Race Cars
Sample Output 2
False
def is_palindrome(string):
string=string.lower()
string=string.replace(" ", "")
if(string == string[::-1]):
return True
else:
return False
string=input()
print(is_palindrome(string))
Comments
Leave a comment