Print Right Triangle Pattern

Print right triangle using stars.

IntermediatePhase 2 - Level 4: Pattern PrintingExample 1 of 13
print-right-triangle-pattern.py
1# Take n
2n = int(input("Enter number of rows: "))
3
4# Print right triangle
5for i in range(1, n + 1):
6 for j in range(1, i + 1):
7 print("*", end="")
8 print()

Output

Enter number of rows: 5
*
**
***
****
*****

What's going on

Outer loop controls rows, inner loop prints stars.

Key Concepts:

Outer loop: rows from 1 to n
Inner loop: print i stars
Newline after each row