Instagram
youtube
Facebook
Twitter

Python Program to Print Right Half Pyramid Pattern

    

A Python Program to Print Right Half Pyramid Pattern

 
Short Description:
This program prints a right-aligned half pyramid using asterisks (*), where each row has increasing stars and decreasing spaces to form a slanted pattern.
Explanation:

  • rows = int(input(...)) → Takes the number of rows as input.
     
  • for i in range(1, rows + 1) → Outer loop for each row.
     
  • " " * (rows - i) → Adds spaces on the left to align the stars to the right.
     
  • "*" * i → Prints i stars in each row.

Program:

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

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

    print(" " * (rows - i) + "*" * i)