Print Right Triangle Pattern

Print right triangle using stars.

Logic BuildingIntermediate
Logic Building
# Take n
n = int(input("Enter number of rows: "))

# Print right triangle
for i in range(1, n + 1):
    for j in range(1, i + 1):
        print("*", end="")
    print()

Output

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

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