Discuss / Python / 交作业

交作业

Topic source

This_is_PYj

#1 Created at ... [Delete] [Delete and Lock User]
def triangles():
    L=[1]
    while 1:
        yield L
        L=[1]+[L[i]+L[i+1] for i in range(len(L)-1)]+[1]

这个while 1:是什么意思啊?

This_is_PYj

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

你也可以写成是while true: 这个都可以的

itomsu

#4 Created at ... [Delete] [Delete and Lock User]
def triangles():
    L = [1]
    while True:
        yield L
        L = [1] + [L[i-1]+L[i] for i in range(len(L)) if i > 0] + [1]

  • 1

Reply