Editor

Star Staircase

#552 · Loops · Beginner · 30 XP · about 5 min

Write staircase(n) that returns a staircase of n steps as a list of strings, one string per line. Line 1 has one star (*), line 2 has two, and so on down to n stars on the last line.

Every line is exactly n characters wide: spaces fill the left side, so the steps line up on the right. For n = 0 return an empty list.

Examples

staircase(3)  # returns ['  *', ' **', '***']
staircase(1)  # returns ['*']

Printed one line at a time, staircase(4) looks like this:

   *
  **
 ***
****

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.