#55EasyLoops· Nested Loops
Pattern Printing with Nested Loops
Input format
`kind`: one of the names above (or anything else). `n`: the size.
Output format
A list of strings, one per row.
Examples
Input: kind = "pyramid", n = 3
Output: [" *"," ***","*****"]
Row 0 has 2 spaces and 1 star, row 1 has 1 space and 3 stars, row 2 has 5 stars.
Input: kind = "hollow_square", n = 4
Output: ["****","* *","* *","****"]
Only the first and last rows are full; the middle rows have stars at both ends.
Constraints
- 1 <= n <= 20
Study first
- #python
- #loops
- #nested-loops
- #patterns
