Discuss / Python / 自己写的,感觉行数太多了

自己写的,感觉行数太多了

Topic source

椒图KaiToU

#1 Created at ... [Delete] [Delete and Lock User]
def yang(n):
    l=[1,1]
    k=1
    if n==1:
        l=[1]
        print([1])  
    elif n==2:
        print(1)
        print(l)
    else: 
        while k<=n:
            i=0
            l.append(0)
            g=list(l)
            g.reverse()
            l=[g[i]+l[i] for i in list(range(k))]
            yield(l)
            k=k+1

y=yang(10)
for x in y:
    print(x)

  • 1

Reply