Discuss / Python / 2022/7/6

2022/7/6

Topic source

留君于心

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

def triangles():

    L = [1]

    while True:

        yield L

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

results = []

for t in triangles():

    results.append(t)

    if len(t) == 10:

        break

print(results)


  • 1

Reply