Discuss / Python / 这样为什么不对

这样为什么不对

Topic source

这样写在列表生成式的时候会将L变为[],想问一下是为什么 def triangles(): L = [1] while True: yield L L = [L[i]+L[i+1] for i in range(1,len(L))] L.append(1)


  • 1

Reply