Discuss / Python / 回数

回数

Topic source

最帅的仔

#1 Created at ... [Delete] [Delete and Lock User]
def is_palindrome(n):
    if not isinstance(n, int):
        raise TypeError('参数不是数字')
    a = list(str(n))
    return a == list(reversed(a))

# 或者

def is_palindrome(n):
    if not isinstance(n, int):
        raise TypeError('参数不是数字')
    s = str(n)
    return s == s[::-1]

  • 1

Reply