Discuss / Python / 借鉴的别人的成果

借鉴的别人的成果

Topic source

fressman

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

def triangles(x): b=[1,] while True: yield b

    b=[1]+[b[i]+b[i+1] for i in range(len(b)-1)]+[1]

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

注:>>>list(range(0))

[]

这是一个空集,所以[1]+[]+[1],返回的是[1,1]


  • 1

Reply