A five-line triangle of stars

Write code · Basic · §7.6 Nested loops and the first math helper

Print n lines of stars, adding one more star on each line: 1 star on the first line, 2 on the second, and so on. Use a loop to print them instead of writing out the stars for each line, as in print("*****").

Starter code

n = 5

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.