Right-Aligned Staircase
This exercise trains working with strings, spaces, and text alignment. The function staircase receives a height n and builds a staircase using the # character. Each next row has one more hash, and the whole staircase is right-aligned to width n. Return the finished rows as a list of strings.
Примеры
Ввод
4Вывод
[" #", " ##", " ###", "####"]Ввод
1Вывод
["#"]Ввод
2Вывод
[" #", "##"]Нужно реализовать
def staircase(n: int) -> list[str]:
Теги
stringsmath
Prijavite se za ogled zgodovine oddaj
PrijavaPrijavite se za uporabo mentorja UI
PrijavaVisible tests
1
Input
4Expected
[" #"," ##"," ###","####"]2
Input
1Expected
["#"]3
Input
2Expected
[" #","##"]4
Input
3Expected
[" #"," ##","###"]5
Input
6Expected
[" #"," ##"," ###"," ####"," #####","######"]6
Input
0Expected
[]Focus radio
Paused · SomaFM · Fluid