Palindrome

A palindrome is anything that reads the same backward and forward. In other words after reversing any number, word or phrase if it remains the same as original then it is a palindrome.

Logic

To check whether a number is a palindrome number or not we have to reverse it first. After reversing it we compare the reversed number with the original number. If both the numbers are similar then it means the number we have is a palindrome number.

Program

# Take input from user
num = input("Enter any number : ")

# Reverse the number
reverse = str(num)[::-1]

# Empty print statement for new line
print()

# Check for palindrome
if reverse == num:
    print(num, "is a palindrome.")
else:
    print(num, "is not a palindrome.")

Output

Enter any number : 121
121 is a palindrome.