Instagram
youtube
Facebook
Twitter

Python Program to Print Inverted Half Pyramid Pattern of Numbers

   Python Program to Print Inverted Half Pyramid Pattern of Numbers
    

    Short Description:
    This program prints an inverted half pyramid made of increasing numbers in each row.
    The number of elements decreases by one in each new row from top to bottom.

    Explanation:

  • rows is the number of rows the user wants.
     
  • The outer loop (i) runs from rows down to 1 — this controls the number of values per row.
     
  • The inner loop (j) prints numbers starting from 1 up to i in each row.
     
  • end=" " keeps numbers on the same line with spaces between them.
     
  • After each row, print() moves to the next line.

Program:

rows = int(input("Enter the number of rows: "))

for i in range(rows, 0, -1):

    for j in range(1, i + 1):

        print(j, end=" ")

    print()