livepython.net

88. Python Program to Print a Star Triangle

MediumNested loops

Overview

Nested loops: the outer loop makes the rows, the inner loop fills them.

Problem Statement

Read a whole number n (1 or more) and print a triangle of n rows: row 1 has 1 star, row 2 has 2 stars, and so on. For example, for 4:

*
**
***
****

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One value per line, in this order. Example:

4

Output

The output for that example:

*
**
***
****

The tests try 3 different inputs.

Learn this firstChapter 10 · Nested Loops, break and continue in Python
solution.py
# write your code here

EXPECTED OUTPUT

1*
2**
3***
4****

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.