Discuss / Python / 写的有点乱

写的有点乱

Topic source

xiaofeig002

#1 Created at ... [Delete] [Delete and Lock User]
def trianbles(max):
    n, l=0, [1]
    while n<max:
        yield(l)
        l.append(0)
        l2=[1]
        for i in range(0,len(l)-1):
            l2.append(l[i]+l[i+1])
        l=l2
        n=n+1
    return "done"

g=trianbles(10)
print(isinstance(g, Iterable))
for i in g:
    print(i)

  • 1

Reply