Discuss / Python / 作业

作业

Topic source

Roger_R36

#1 Created at ... [Delete] [Delete and Lock User]
    m = 1
    L = []
    while True:
        if m == 1:
            L = [1]
            yield L
        elif m == 2:
            L = [1,1]
            yield L
        else:
            LL = list(range(m))
            for x in range(m):
                if x == 0:
                    LL[x] = 1
                elif x == m-1:
                    LL[x] = 1
                else:
                    LL[x] = L[x-1] + L[x]
            L = LL
            yield LL
        m = m + 1

  • 1

Reply