Read n and print a right triangle of stars: line 1 has one *, line 2 has two, and so on up to line n.
What to build
A pattern in which each line depends on the loop variable.
Requirements
- Read
n. - Print a line of
istars for eachifrom 1 ton.
Input
One whole number n from 1 to 50.
Output
n lines of stars.
Constraints
n is from 1 to 50.
Example
Input:
3
Output:
*
**
***
Why it works
"*" * i repeats the text i times, so one loop is enough.
Examples
Example 1 · Input
3
Expected output
* ** ***
Example 2 · Input
1
Expected output
*
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
"*" * 3 gives "***".
Solution
Show one correct solution (try it yourself first)
n = int(input())
for i in range(1, n + 1):
print("*" * i)