Letter Staircase
Here the string turns into a neat letter staircase: each next character is repeated one more time than the previous one. Write accum, which creates a group for each character in s: the first copy is uppercase, and the rest are lowercase. Join the groups with -.
Примеры
Ввод
"abcd"Вывод
"A-Bb-Ccc-Dddd"Ввод
"RqaEzty"Вывод
"R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"Ввод
"cwAt"Вывод
"C-Ww-Aaa-Tttt"Нужно реализовать
def accum(s: str) -> str:
Теги
strings
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesiónVisible tests
1
Input
"abcd"Expected
"A-Bb-Ccc-Dddd"2
Input
"RqaEzty"Expected
"R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"3
Input
"cwAt"Expected
"C-Ww-Aaa-Tttt"4
Input
"a"Expected
"A"5
Input
"ZpglnRxqenU"Expected
"Z-Pp-Ggg-Llll-Nnnnn-Rrrrrr-Xxxxxxx-Qqqqqqqq-Eeeeeeeee-Nnnnnnnnnn-Uuuuuuuuuuu"6
Input
"Hello, World!"Expected
"H-Ee-Lll-Llll-Ooooo-,,,,,,- -Wwwwwwww-Ooooooooo-Rrrrrrrrrr-Lllllllllll-Dddddddddddd-!!!!!!!!!!!!!"Focus radio
Paused · SomaFM · Fluid