Instagram
youtube
Facebook
Twitter

Python Program to Print Right-Aligned Inverted Half Pyramid Pattern

   Python Program to Print Right-Aligned Inverted Half Pyramid Pattern
     

     Short Description:
     
This program prints a right-aligned inverted half pyramid using asterisk (*).
     It decreases the number of stars in each row and shifts them to the right using spaces.

     Explanation:

  • rows is the total number of rows.
     
  • The loop runs from rows down to 1.
     
  • For each row:
     
  • It prints spaces first to push the stars to the right.
     
  • Then it prints i stars, where i decreases each time.

Program:

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

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

    spaces = rows - i

    print(" " * spaces + "*" * i)