Python Practice › Loop Programs › Program 53

Right triangle of stars

EasyLoop Programs · 53 of 90

Write a Python program to print a right triangle of stars with 5 rows.

Advertisement
Output
* 
* * 
* * * 
* * * * 
* * * * * 

Approach

  1. Row i prints i stars.

Solution

Python
for i in range(1, 6):    print("* " * i)
Output
* 
* * 
* * * 
* * * * 
* * * * * 

Line by line

Line 2

Repeating “* ” i times builds row i.

Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More loop programs

← All 90 Loop Programs