Discuss / Python / 我这个应该挺好理解吧

我这个应该挺好理解吧

Topic source

def triangles():

    last=[1]

    while True:

        yield last

        next=[last[n-1]+last[n] for n in range(1,len(last))] #先构建中间的元素

        next=[1]+next+[1]  #首尾+1

        last=next

认真学习了,受益非浅


  • 1

Reply