def triangles():
L0 = [1,1] n = 1 while True: L = [] for i in range(n): if i == 0 or i == n-1: L.append(1) else: L.append(L0[i]+L0[i-1]) yield L L0 = L n = n + 1
n = 0 for t in triangles(): print(t) n = n + 1 if n == 10: break
Sign in to make a reply
HIT_Owen
def triangles():
n = 0 for t in triangles(): print(t) n = n + 1 if n == 10: break