Discuss / Python / 作业

作业

Topic source

Gussun

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

def triangles():
    L=[1,]
    while(True):
        yield L 
        i=len(L)-1
        while(i):
            L[i]=L[i]+L[i-1]
            i-=1
        L.append(1)

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

Henry_Smith

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

寫的到位。赞!

这个程序写得非常好!精简干练!


  • 1

Reply