Discuss / Python / 交作业,欢迎指正

交作业,欢迎指正

Topic source

小神CaT

#1 Created at ... [Delete] [Delete and Lock User]
from functools import reduce

def is_palindrome(n):
    def fn(x,y):
        return x*10+y
    L = []
    for i in str(n):
        L.append(i)
    b = list(map(int,L))
    if len(L) == 1:
        return b
    else:
        for i in range(int(len(L)/2)):
            if L[i] == L[-i-1]:
                return (reduce(fn,b))

  • 1

Reply