Program to Check if a Number is a Palindrome in Python
Palindrome Number
A palindrome number is a number that remains the same when its digits are reversed. For example, 121 and 1331 are palindrome numbers.
We will explore a method to check if a number is a palindrome using Python programming.
Method: Using String Manipulation
We convert the number to a string and check if it reads the same forward and backward.
num = input("Enter a number: ") # Check if the number reads the same forward and backward if num == num[::-1]: print(f"{num} is a palindrome number") else: print(f"{num} is not a palindrome number")
Output:
Enter a number: 121 121 is a palindrome number