def triangles():
L = [1]
while True:
yield L
L.append(0)
L = [L[i - 1] + L[i] for i in range(len(L))]
n = 0
for t in triangles():
print(t)
n = n + 1
if n == 10:
break
L = [L[i - 1] + L[i] for i in range(len(L))] 这一段列表生成怎么理解,i一开始不应该是0吗,那L[i-1]不就是L[-1]?哪里理解的不对呢
微笑的小二
相关分类