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
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