杨辉三角
Topic sourcedef triangles():
list =[]
while True:
a,b = 0,0
newlist = []
for x in list:
a = b
b = x
newlist.append(a+b)
newlist.append(1)
list = newlist
yield newlist
- 1
张文范
def triangles(): list =[] while True: a,b = 0,0 newlist = [] for x in list: a = b b = x newlist.append(a+b) newlist.append(1) list = newlist yield newlist