Duplicate Characters
This transformation is a good way to practice walking through a string and building new text. Write a function double_char that takes a string s and returns a new string where every character is repeated twice in a row. Repeat everything: letters, spaces, hyphens, and any other characters.
Примеры
Ввод
"The"Вывод
"TThhee"Ввод
"AAbb"Вывод
"AAAAbbbb"Ввод
"Hi-There"Вывод
"HHii--TThheerree"Нужно реализовать
def double_char(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
"The"Expected
"TThhee"2
Input
"AAbb"Expected
"AAAAbbbb"3
Input
"Hi-There"Expected
"HHii--TThheerree"4
Input
""Expected
""5
Input
"a"Expected
"aa"6
Input
" "Expected
" "Focus radio
Paused · SomaFM · Fluid