Loops and patterns · Python exercise
Print a left-aligned triangle of stars for a given height.
Read a positive integer n and print a triangle with n rows. Row 1 has one star, row 2 has two stars, and so on.
Example 1
Input
3
Output
* ** ***
Example 2
Input
1
Output
*
How testing works
Your code runs once per test case with that case's standard input. Output is compared after normalising trailing spaces and blank lines at the end. Use input() without a prompt when the exercise expects clean output.
Loading editor…
Press Run tests to execute your code against every input case. Python runs in a Web Worker in your browser.