Python program to print star pattern (right triangle)

Description: Write a Python program to print a right angled triangle pattern of stars with 5 rows.

Rules and hints:

  • Row 1 has one star, row 2 has two stars, and so on.
  • You can repeat a string with *, like "*" * 3.

Python star pattern program

rows = 5

for i in range(1, rows + 1):
    print("*" * i)

Output:

Tutorials Class - Output Window

*
**
***
****
*****

How it works

  • In round i we print the star i times.
  • print() adds a new line after each row.

Related: Python Strings.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.