Pattern Display
*
* *
* * *
* * * *
* * * * *
Implementation
n = 5
for i in range(1, n + 1): # Outer loop for rows
for j in range(i): # Inner loop for stars
print("*", end=" ")
print() # Moves to the next line
Steps
Identify Rows and Columns
- The number of rows (
n
) determines the height of the pattern. - Each row
i
containsi
stars (*
).
Looping Strategy
- Use an outer loop for rows (
i
from1
ton
). - Use an inner loop for columns (print
i
stars in thei
th row).
Printing Output
- Print stars on the same line using
end=" "
to maintain spacing. - After finishing one row, move to the next line using
print()
.
Pattern Output
*
* *
* * *
* * * *
* * * * *