Growing Prefixes
This function practices working with prefixes: pieces of a string that start at the beginning and grow one character at a time. Write a function string_splosion that takes a string s and builds a new string from all of its growing prefixes. For Code, join C, then Co, then Cod, then Code to get the final result.
Примеры
Ввод
"Code"Вывод
"CCoCodCode"Ввод
"abc"Вывод
"aababc"Ввод
"ab"Вывод
"aab"Нужно реализовать
def string_splosion(s: str) -> str:
Теги
strings
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible tests
1
Input
"Code"Expected
"CCoCodCode"2
Input
"abc"Expected
"aababc"3
Input
"ab"Expected
"aab"4
Input
"x"Expected
"x"5
Input
"fade"Expected
"ffafadfade"6
Input
""Expected
""Focus radio
Paused · SomaFM · Fluid