Answer to Question #245123 in Python for Raju

Question #245123

Hollow Inverted Full Pyramid - 2

Given the number of rows N, write a program to print the hallow inverted full pyramid pattern similar to the pattern shown below.

1 2 3 4 5 

 1    4 

  1   3 

   1 2 

   1


1
Expert's answer
2021-10-05T02:32:25-0400
n = int(input())
s = ''
for el in range(1,n+1):
	s += str(el) + ' '
s+= '\n'
for i in range(1, n-1):
	s += ' '*i + '1 ' + ' '*(n-(2*i)+1) + f'{n-i}'
	s += '\n'
s += ' '*(n-1) + '1'
print(s)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS