Discuss / Python / 初学菜狗

初学菜狗

Topic source
def store(max):
    start = 10
    while start < max:
        yield start
        start += 1

def fib(x):
    x = str(x)
    lens = len(x)
    start = 1
    rs = True
    for v in range(1,lens // 2 + 1):
        if x[:start] != x[-start:]:
            rs = False
    return rs

def palindrome(max = 1000):
    l = store(max)
    return filter(fib,l)

for x in palindrome():
    print(x)

  • 1

Reply