Problem 114182 · easy · Phase 01 Prerequisites & Setup

Right-Aligned Staircase

nested loops · strings · lists

Build a staircase that leans against the right wall. Given n, return a list of n strings. Row i (counting from 1) contains i stars (*) preceded by enough spaces so that every row is exactly n characters wide.

Examples

Input:  n = 3
Output: ["  *", " **", "***"]

Input:  n = 1
Output: ["*"]

Constraints

  • 0 <= n <= 50
  • Return an empty list when n is 0.

Goals

  • Build each row from a count of spaces and a count of stars
  • Collect rows into a list instead of printing them
Starting Python…