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
icontainsistars (*).
Looping Strategy
- Use an outer loop for rows (
ifrom1ton). - Use an inner loop for columns (print
istars in theith 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
*
* *
* * *
* * * *
* * * * *
