Hollow Full Pyramid - 2
Given the number of rows N, write a program to print the hallow full pyramid pattern similar to the pattern shown below.
1
1 2
1 3
1 4
1 2 3 4 5
N = int(input())
for i in range (1, N+1):
for j in range(i,N):
print(" ",end='')
z = 0
for j in range(1, i+1):
if(j == 1 or i == N):
print(str(j) + " ",end='')
else:
if z!=0:
print(" ",end='')
z=1
for j in range(1,i):
if(j == i-1 and j < N-1):
print(str(j+1)+" " ,end='');
else:
if z!=0:
print(" ",end='')
z=1
print("")
Comments
Leave a comment