Discuss / Python / 过滤

过滤

Topic source

Nghg

#1 Created at ... [Delete] [Delete and Lock User]

def is_palindrome(n):

    if n < 10:

        return True

    numStr = str(n)

    length = len(numStr)

    for index, value in enumerate(numStr):

        rightIndex = length - 1 - index

        if index != rightIndex and value != numStr[rightIndex]:

            return False

    return True


  • 1

Reply