All problems
Palindrome Number
Problem
Return True if the integer x reads the same forwards and backwards, and False otherwise.
Negative numbers are never palindromes because of the minus sign. Reverse the digits arithmetically and compare with the original.
Hint
Building the reversed number with rev * 10 + digit avoids converting to a string.
Test cases
case 1
in: [121]
expected: true
case 2
in: [-121]
expected: false
case 3
in: [10]
expected: false
case 4
in: [0]
expected: true
case 5
in: [12321]
expected: true
Starter codePython
def palindrome_number(x):
# Your code here
pass5 test cases · run your code against them in the editor