Discuss / Python / 作业

作业

Topic source

微尘初心

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

def triangles():

    n = 1

    L = [1]

    yield L

    L = [1, 1]

    yield L

    while True:

        L = [1, 1]

        if n == 1:

            new_L = L

        for i in range(1, n+1):

            L.insert(i, new_L[i-1]+new_L[i])

        new_L = L

        yield new_L

        n += 1


  • 1

Reply