```
class Solution:
# @return a boolean
def isPalindrome(self, x):
#negative numbers are not palindromes, return 0
if x<0:
return 0
x=str(x)
#making sure the length is greater than 1, otherwise it's always a palindrome
while len(x)>1:
#check the first and last digits to see if they are equal
while x[0]==x[len(str(x))-1]:
#if yes, take out those digits, repeat the process until there's only 1 digit left
x=x[1:len(x)-1]
#if there's only one or no digit left after repeatedly taking out digits, it's a palindrome
if len(x)==1 | len(x)==0:
return 1
#if the first and last digits do not equal to each other, return 0 as it's not a palindrome
else:
return 0
else:
return 1
```

Since the definition states that negative numbers are not palindromes, I only cared about non-negatives. I do it by repeatedly taking out first and last digits of a string (after converting and replacing the original input, thus no extra space) until there's only 1 or no digit left. If that happens, it's a palindrome.

However, I run into Index error when executing. Is it because that once a string has no digit, it cannot be indexed (as len(x) will not return an answer)?