Discuss / Python / 作业

作业

Topic source

Rayn-S

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

不太满意。学习一下大家的吧。

def triangles():
    yield [1]
    yield [1,1]
    last = [1,1]
    while True:
        t = tuple(last)
        n = 1
        while n < len(t):
            last[n] = t [n] + t[n-1]
            n = n+1
        last.append(1)
        yield last[:]

  • 1

Reply