Learn practical skills, build real-world projects, and advance your career
Updated 2 years ago
9-palindrome-number
Given an integer x, return true if x is a palindrome, and false otherwise.
!pip install jovian --upgrade --quiet
import jovian
brute force:
- loop through each input digit backwards and add each result to a new string.
- compare new string to old input integer as string
- leading zeros in decimal integer literals shouldn't be an issue since the input is specifically an integer
def isPalindrome(x):
x2 = str(x)[::-1]
if x2 == str(x):
return True
else:
return False