Palindrome number

A palindrome is a word that has the same meaning when read backwards as when read from the front. Examples of palindromes are: Anna, madam, level, racecar and many more.
Mathematics also knows palindromes. Here we talk about palindromes if the numbers do not change when the sequence of numbers is reversed, for example 22 or 141.

Check Palindrome number

rev = 0
x = int(input("Enter number to check palindrome or not: "))
temp = x

while x > 0:
    r = x % 10
    rev = rev * 10 + r
    x = x // 10

if temp == rev:
    print(str(temp) + " is palindrome number")
    print(str(temp) + " is not palindrome number")
Enter number to check palindrome or not: 262
262 is palindrome number

Enter number to check palindrome or not: 13
13 is not palindrome number

Check Palindrome string

s = "anna"
if s == s[::-1]:
    print(s + " is a palindrome")
    print(s + " is not a palindrome")
anna is a palindrome