How to print a Pythagorean pyramid in python?
I wrote this program to print the Pythagorean pyramid with its triangular shape. It can print it up to a certain point (before two-digit numbers appear). After that, the shape is distorted. How can I fix this?
l=[[1],[1,1]]
n=int(raw_input("Number:"))
for x in range(2,n):
l2=[1,]
for y in range(x-1):
l2.append(l[x-1][y]+l[x-1][y+1])
l2.append(1)
l.append(l2)
for x in range(n):
print " "*(n-x-1),
for y in l[x]:
print y,
print
+3
source to share