Palindrome number
Write a program to determine if given number is palindrome or not. Print true if it is palindrome, false otherwise.
Palindrome are the numbers for which reverse is exactly same as the original one.
CODE:
def reverse(n):
rev = 0
while(n >0):
rem = n % 10
rev = (rev * 10) + rem
n = n//10
return rev
def checkPalindrome(num):
rev = reverse(num)
if rev == num:
return 1
else:
return 0
num = int(input())
isPalindrome = checkPalindrome(num)
if(isPalindrome):
print('true')
else:
print('false')
Test cases
Sample Input 1 :
121
Sample Output 1 :
true
Sample Input 2 :
1032
Sample Output 2 :
false
No comments:
Post a Comment