1n = input("Enter the word and see if it is palindrome: ") #check palindrome
2if n == n[::-1]:
3 print("This word is palindrome")
4else:
5 print("This word is not palindrome")
1mes=input("Enter the word and see if it is palindrome ")
2if mes==mes[::-1]:
3 print("This word is palindrome")
4else:
5 print("This word is not palindrome")
1number=int(input("Enter any number :"))
2#store a copy of this number
3temp=number
4#calculate reverse of this number
5reverse_num=0
6while(number>0):
7 #extract last digit of this number
8 digit=number%10
9 #append this digit in reveresed number
10 reverse_num=reverse_num*10+digit
11 #floor divide the number leave out the last digit from number
12 number=number//10
13#compare reverse to original number
14if(temp==reverse_num):
15 print("The number is palindrome!")
16else:
17 print("Not a palindrome!")
1#A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward.
2#Ex: madam or racecar.
3def is_palindrome(w):
4 if w==w[::-1]: # w[::-1] it will reverse the given string value.
5 print("Given String is palindrome")
6 else:
7 print("Given String is not palindrome")
8
9is_palindrome("racecar")