Answer to Question #242281 in Python for saras

Question #242281

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-09-25T17:47:37-0400
N = int(input("Enter the Number: "))


for i in range(1, N+1):
    for j in range(0, i):
        print(" ", end="")


    for j in range(1, (N*2 - (2*i - 1))+1):
        if i == 1 or j == 1 or j ==(N*2 -(2*i-1)):
            print(j, end="")
        else:
            print(" ", end="")
    print()

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