Python program to check if the given number is palindrome or not

To check if a given number is a palindrome, you can convert it to a string and then compare it with its reverse. If they are the same, then the number is a palindrome. Here's a Python program to do that:


def is_palindrome(number):

# Convert the number to a string

number_str = str(number)

# Compare the string with its reverse

return number_str == number_str[::-1]

# Example usage:

input_number = int(input("Enter a number: "))

if is_palindrome(input_number):

print("The number is a palindrome.")


print("The number is not a palindrome.")


This program prompts the user to input a number, converts it to a string, compares it with its reverse, and then prints whether the number is a palindrome or not.