tags:
- code
topic: List
difficulty: Intermediate
link: https://www.codewars.com/kata/576757b1df89ecf5bd00073b
date: 2023-12-31
Problem
Build a pyramid-shaped tower, as an array/list of strings, given a positive integer
number of floors
. A tower block is represented with"*"
character.
For example, a tower with3
floors looks like this:
[
" * ",
" *** ",
"*****"
]
def tower_builder(n_floors):
return [(("**"*i)[:-1]).center((n_floors*2)-1) for i in range(1,n_floors+1)]