Discuss / Python / 用户6589242306 老哥牛逼

用户6589242306 老哥牛逼

Topic source

def triangles(x):

    L = [1]

    n = 1

    while n <= x:

        yield L

        L = [0] + L + [0]

        L = [L[i] + L[i + 1] for i in range(len(L) - 1)]

        n+=1

t = triangles(10)

print(t)

for i in t:

    print(i)


  • 1

Reply