Star staircase
Inputs
n is a whole number from 0 to 10.
Your tasks
- Create an empty list
rows. - Use an outer loop for each row number
rfrom 1 up to and includingn. Build a textlinewith an inner loop that adds one "*" for each of therpositions. - Add
linetorows. - Complete
staircaseso it returnsrows. Return it, do not print it.
Example
With n = 4, staircase returns ["*", "**", "***", "****"].
Rules
- Row 1 has one star, row 2 has two, and so on.
- If
nis 0, return an empty list.
Test data
TEST DATA 1: n is 4
TEST DATA 2: n is 0
Practice focus
Nested loops compare every pair and build rows. The slow, simple answer to most problems is two loops. Knowing it is what lets you see how to beat it.