Please tell me what is wrong with my code.
The function returned False
for the palindrome(11)
and True
for some cases.
Below is the code :
def palindrome(x):
if(x < 0 or (x%10 == 0 and x != 0)):
return False
revertedNumber = 0
while(x > revertedNumber):
revertedNumber = revertedNumber * 10 + x%10
x = x/10
return(x == revertedNumber or x == revertedNumber/10)
Above code returned false for the input 11