31
Question Write a Python function that checks whether a passed string is a palindrome or not.
Note: A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run.
def is_palindrome(s):
s = s.lower()
return s == s[::-1]
input_string = input("Enter a string: ")
if is_palindrome(input_string):
print(input_string, "is a palindrome.")
else:
print(input_string, "is not a palindrome.")Enter a string: madam
madam is a palindrome.
Enter a string: nursesrun
nursesrun is a palindrome.
Enter a string: watermelon
watermelon is not a palindrome.