Half pyramid with numbers but the numbers printed from below like input 1and 3
Output will be
6
5 4
3 2 1
def display( n) :
k = 0
m2=1
for i in range(1,n+1) :
m1=0
for j in range(i,n) :
print(' ', end='')
while (k != (2 * i - 1)) :
# if (k == 0 or k == 2 * i - 2) :
if (k == 0) :
m1+=1
print(m1, end='')
elif (k == 2 * i - 2) :
m2+=1
print(m2, end='')
else :
print(' ', end ='')
k = k + 1
k = 0;
print ("")
for i in range(1, 2 * n ) :
print (i, end = '')
n = 4
display(n)
Comments
Leave a comment