Letter Pattern
This is a great way to practice strings, indices, and letter case. Write a function accum that turns the string s into a chain of parts separated by hyphens. For each letter, use its position i: start with the uppercase version, then add i more copies of the same letter in lowercase.
Примеры
Ввод
"abcd"Вывод
"A-Bb-Ccc-Dddd"Ввод
"RqaEzty"Вывод
"R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"Ввод
"cwAt"Вывод
"C-Ww-Aaa-Tttt"Нужно реализовать
def accum(s: str) -> str:
Теги
strings
Logga in för att se historik över inskick
Logga inLogga in för att använda AI-mentorn
Logga inVisible 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
"cwAt!"Expected
"C-Ww-Aaa-Tttt-!!!!!"Focus radio
Paused · SomaFM · Fluid