Every Other Letter
Sometimes you need to take only every second character from text, such as for a simple filter or index practice. Write a function string_bits that takes a string s and returns a new string made from characters at indices 0, 2, 4, and so on. In other words, take the first character, skip the next one, then take the next again.
Примеры
Ввод
"Hello"Вывод
"Hlo"Ввод
"Hi"Вывод
"H"Ввод
"Heeololeo"Вывод
"Hello"Нужно реализовать
def string_bits(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
"Hello"Expected
"Hlo"2
Input
"Hi"Expected
"H"3
Input
"Heeololeo"Expected
"Hello"4
Input
"abc"Expected
"ac"5
Input
"Hello, World!"Expected
"Hlo ol!"6
Input
""Expected
""Focus radio
Paused · SomaFM · Fluid