def tri(): L = []; i = 0 while True: L.append([]) for j in range(0,i+1): if j == 0 or i == j: L[i].append(1) else: L[i].append(L[i-1][j-1] + L[i-1][j]) yield(L[i]) i = i+1 return 'Done'
a = tri() next(a) next(a) ......
你好,请问为什么需要L.append([])?
Sign in to make a reply
zH倫0rz
def tri(): L = []; i = 0 while True: L.append([]) for j in range(0,i+1): if j == 0 or i == j: L[i].append(1) else: L[i].append(L[i-1][j-1] + L[i-1][j]) yield(L[i]) i = i+1 return 'Done'
a = tri() next(a) next(a) ......