python杨辉三角

杨辉三角

a=[0,1,0]
b=[]
c=[[]]
for j in range(10):

c.append([])
c[0]=a


for i in range(len(c[j])-1):
    c[j+1].append(c[j][i]+c[j][i+1])
c[j+1].insert(0,0)
c[j+1].append(0)

for data in c:
data.remove(0)
data.pop()
print(data)

猜你喜欢

转载自blog.csdn.net/weixin_32759777/article/details/81410956