68,628 views
15 votes
15 votes
Please code in python and add comments to code

Question:
Get a 4 or more digit number from the user and check if the number is Palindrome Number.

User Shivani Katukota
by
3.2k points

1 Answer

9 votes
9 votes

#accepting input from user

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

#entered number is stored in a temporary variable

temp=n

#initializng required variables

rev=0

dgt=0

#digits are reversed inside while loop

while(n>0):

dgt=n%10

rev=rev*10+dgt

n=n//10

#original number and its reverse are compared

if(temp==rev):

#if equal, it's a palindrome

print("It is a Palindrome")

else:

#if not equal, it's not a palindrome

print("It is not a Palindrome")

#◌⑅⃝●♡⋆♡Nåmřāthā♡⋆♡●⑅◌

User Guerschon
by
3.1k points