Discuss / Python / 重新定义L

重新定义L

Topic source

Vency_熙爷

#1 Created at ... [Delete] [Delete and Lock User]

def triangles(a): L = [1] n = 0 while n < a: yield L L.append(0) L = [L[i - 1] + L[i] for i in range(len(L))] n = n + 1 return L

for n in triangles(10): print(n)


  • 1

Reply