Read the question, write Python on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read n and print a right triangle of asterisks with n rows.
Row i has i stars and no extra spaces. This is the classic nested-loop pattern.
Input. One line: an integer n ≥ 1.
Output. n lines of *, **, ***, …
Constraints
- 1 ≤ n ≤ 20
Examples
Input
3
Output
* ** ***
Hint
- print("*" * i) for i in 1..n.
- Nested loops work too: an inner loop that prints i stars.
Show correct code
Peek only after you have tried. You can still Check your own version.
n = int(input())
for i in range(1, n + 1):
print("*" * i)
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.