Duplicate Characters
This works like a simple text effect: every character needs to be duplicated. Write a function double_char that takes a string s and returns a new string where each character from the original string appears twice in a row. Spaces, hyphens, and any other characters should be doubled too.
Примеры
Ввод
"The"Вывод
"TThhee"Ввод
"AAbb"Вывод
"AAAAbbbb"Ввод
"Hi-There"Вывод
"HHii--TThheerree"Нужно реализовать
def double_char(s: str) -> str:
Теги
strings
Idħol biex tara l-istorja tas-sottomissjonijiet
IdħolIdħol biex tuża l-Mentor tal-AI
IdħolVisible tests
1
Input
"The"Expected
"TThhee"2
Input
"AAbb"Expected
"AAAAbbbb"3
Input
"Hi-There"Expected
"HHii--TThheerree"4
Input
""Expected
""5
Input
"the"Expected
"tthhee"6
Input
"THE"Expected
"TTHHEE"Focus radio
Paused · SomaFM · Fluid