我的才是标准答案
Topic source我想到的是用双list:
def triangles():
list1 = [1]
list2 = []
while True:
yield list1
list2.append(1)
for i in range(0, len(list1)-1):
list2.append(list1[i]+list1[i+1])
list2.append(1)
list1 = list2
list2 = []
写了个空列表抬手的,不过不如大哥帅
L = []
while True:
L = [L[i] + L[i-1] if i > 0 else 1 for i in range(len(L))]
L.append(1)
yield(L)
- 1
light_the_light