Discuss / Python / 作业

作业

Topic source

wwdx0001

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

def calculatenext(L): L = L[:] L.append(0) L.insert(0,0) for i in range(len(L)): L[i] = L[i]+L[i] return L

def triangles(): L = [1] while 1: yield L L = calculate_next(L)

def main(): n = 0 for t in triangles(): print(t) n = n + 1 if n == 10: break


  • 1

Reply