# Python Program to Find a Number is Palindrome or not

## Find a Number is Palindrome or not

In this Python Program we will find whether a given number is Palindrome or not. A palindrome number means if reverse of a number and original number both are equal then given number is Palindrome or not. First we have to find the reverse of a number using while loop and else if statement. Then we will check condition, if original number is equal to the reverse of a number.
For Example:-
• A number is 526625 .If you read number “526625” from reverse order, it is same as “526625”.
In that  number is a palindrome.
• A number is 13131. If we read number “13131” from reverse order ,it is same as 13131. It is also a palindrome number ### Working:

Step 1. Take the user number for variable number.

Step 2. Take a temp variable and initialized with number value.

Step 3. Take reverse variable and initialized with 0.

Step 4. Run a while until number > 0.

Step 5. Then inside while loop, Obtain remainder.

Step 6. Multiply the reverse variable with 10 and add the obtained remainder to it.

Step 7. Now, divide number by 10 and stored it again in number variable.

Step 8. Repeat Step 5,6,7 until while loop condition gets false.

Step 9, Now, Outside the while loop Check temp == reverse. If this condition is true, then print, “Given number is Palindrome”.

Step 10. Else, Print, “Given number is not Palindrome”.

Step 11. Stop.

### Python Program:

```number = int(input("Enter the Number:"))
temp = number
reverse = 0
while number > 0:
remainder = number % 10
reverse = (reverse * 10) + remainder
number = number // 10

if temp == reverse:
print("Given number {} is Palindrome".format(temp))
else:
print("Given number {} is not Palindrome".format(temp))

# This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student) ```

### Output:

Enter the Number:1331
Given number 1331 is Palindrome

### 2 comments on “Python Program to Find a Number is Palindrome or not”

• IPE2K17

#palindrome or not
n=input()
inv_n = n[::-1]
if (n==inv_n):
print(‘Palindrome’) 15
• Raman

a=input()
n=len(a)
c=[]
for i in range(n-1,-1,-1):
c.append(a[i])
print(int(a[i]),end=””)

d=””.join(c)
print()

if(int(a)==int(d)):
print(“palindrome”)
else:
print(“Not Palindrome”) 2