What is a palindrome number:
Python program to check palindrome number:
n = int(input("please give a number : "))
reverse,temp = 0,n
while temp!=0:
reverse = reverse*10 + temp%10;
temp=temp//10;
if reverse==n:
print("number is palindrom")
else:
print("number is not palindrom")
OR
n = int(input("please give a number : "))
def reverse(num):
if num<10:
return num
else:
return int(str(num%10) + str(reverse(num//10)))
def isPalindrome(num):
if num == reverse(num):
return 1
return 0
if isPalindrome(n) == 1:
print("palindrome")
else:
print(" not palindrome")
0 Comments
please dont enter spam comments