Discuss / Python / 作业

作业

Topic source

diasarah

#1 Created at ... [Delete] [Delete and Lock User]
def is_palindrome(n):
    L = [str(x) for x in range(2, n)]
    def is_p(s):
        l = len(s)
        flag = True        for i in range(l//2):
            if s[i]!=s[l-i-1]:
                flag = False                break        return flag
    print(list(filter(is_p,L)))
is_palindrome(1000)

  • 1

Reply