Discuss / Python / 抄作业咯!!!

抄作业咯!!!

Topic source

大神们好厉害……还有好多需要学习的地方!!!(¯﹃¯)

# -*- coding: utf-8 -*-

def triangles():
    L=[1]
    while True:
        yield L
        L.append(0)
        L=[L[i-1]+L[i] for i in range(len(L))]
n=int(input('Please enter a number:'))
m=0    
for t in triangles():
    print(t)
    m=m+1
    if m==n:
        break

  • 1

Reply