Palindrome String: Given a string s, find out whether it is a palindrome or not.

Given a string s, find out whether it is a palindrome or not. A palindrome is a string that reads the same forward and backward. Print 1 if the string is a palindrome and 0 otherwise.

Note: Make sure that your program is not case-sensitive. See example.

Input 1: 'python'
Output 1: 0

Input 2: 'Hannah'
Output 2: 1

# Read the input
s = input()

# First convert the entire string to lower (or alternatively upper) case. Then
# check if the original string is equal to the reversed string. The reverse of the 
# string can be found out using negative indexing as shown below. Finally if they
# are equal print 1 else 0.
print(int(s.lower()==s.lower()[::-1]))

Comments