练习
Topic source厉害,简洁的代码,向你学习,附上我的代码,以作记录。
# -*- coding:utf-8 -*-
def triangles()
n,i = 1,0
L = [0,1,0]
yield L[1:-1]
while True:
former_list = L.copy() #将列表复制
length = len(former_list)
for i in range(length-1):
L[i+1] = former_list[i] + former_list[i+1]
L.append(0)
yield L[1:-1]
- 1
ssaltt