In this python if else program, we will check whether any given number is palindrome number or not.
A palindrome number is a number that remains the same when digits are reversed. For example, the number 121 is a palindrome number, but 253 is not a palindrome number.
Hint:
Use string.
Use indexing.
Steps to solve the program
- Take a number as input.
- Reverse the given number and store it in another variable.
- Check whether both the numbers are equal or not using an if-else statement.
- Print the respective output.
num1 = 121
num2 = str(num1)
if num1 == int(num2[::-1]):
print("It is a palindrome number")
else:
print("It is not a palindrome number")
Output :
It is a palindrome number
Related Articles
Python program to check if any given string is palindrome or not.
Python program to check whether the given number is positive or not.
Python program to check whether the given number is negative or not.
Python program to check whether the given number is positive or negative and even or odd.
Python program to print the largest number from two numbers.