palindrome_number

 1# @leet start
 2class Solution:
 3    def isPalindrome(self, x: int) -> bool:
 4        """
 5        This asks us to check if a number is a palindrome. We can do this
 6        by converting it into its digits and checking if the number is the
 7        same forwards and backwards
 8        """
 9        if x < 0:
10            return False
11
12        l = []
13        while x:
14            x, digit = divmod(x, 10)
15            l.append(digit)
16        rev_l = list(reversed(l))
17        return l == rev_l
18
19
20# @leet end
21
22
23def test():
24    assert 2 + 2 == 4
class Solution:
 3class Solution:
 4    def isPalindrome(self, x: int) -> bool:
 5        """
 6        This asks us to check if a number is a palindrome. We can do this
 7        by converting it into its digits and checking if the number is the
 8        same forwards and backwards
 9        """
10        if x < 0:
11            return False
12
13        l = []
14        while x:
15            x, digit = divmod(x, 10)
16            l.append(digit)
17        rev_l = list(reversed(l))
18        return l == rev_l
def isPalindrome(self, x: int) -> bool:
 4    def isPalindrome(self, x: int) -> bool:
 5        """
 6        This asks us to check if a number is a palindrome. We can do this
 7        by converting it into its digits and checking if the number is the
 8        same forwards and backwards
 9        """
10        if x < 0:
11            return False
12
13        l = []
14        while x:
15            x, digit = divmod(x, 10)
16            l.append(digit)
17        rev_l = list(reversed(l))
18        return l == rev_l

This asks us to check if a number is a palindrome. We can do this by converting it into its digits and checking if the number is the same forwards and backwards

def test():
24def test():
25    assert 2 + 2 == 4