Discuss / Python / 一种思路,两种代码

一种思路,两种代码

Topic source

Gino_wang

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

def is_palindrome(n):

    numSource = str(n)

    antiNumSource = []

    for v in numSource:

        antiNumSource.insert(0,v)

    antiNumSource = ''.join(antiNumSource)

    #print(antiNumSource)

    if numSource == antiNumSource:

         return True

    else:

         return False

===================

def is_palindrome(n):

    LSource = list(str(n))

    LNow = []

    for v in LSource:

        LNow.insert(0,v)

    if LSource == LNow:

        return True

    else:

        return False


  • 1

Reply