Discuss / Python / 交作业

交作业

Topic source
# -*- coding: utf-8 -*-

def triangles():

    i = 1
    L0 = [1]
    while True:
        j, L1 = 1, [1]
        yield L0
        while j < i:
            L1.append(L0[j-1]+L0[j])
            j = j + 1
        L1.append(1)
        L0 = L1
        i = i + 1

  • 1

Reply