Discuss / Python / 参考大神代码交作业

参考大神代码交作业

Topic source

M斯蕾

#1 Created at ... [Delete] [Delete and Lock User]
#杨辉三角
def triangles():
    b=[1]
    while True:
        yield b
        b = [1]+[b[i]+b[i+1] for i in range(len(b)-1)]+[1]


#杨辉三角
from My_Functions import triangles
n=int(input('please input value n:'))
for t in triangles():
    print(t)
    if n == len(t):
        break

  • 1

Reply