Flip Each Word
Sometimes you need to change the inside of each word without moving the words themselves. Write a function reverse_each_word that receives a string s where words are separated by single spaces. Reverse the characters inside every word, but keep the words in their original order. The spaces between words should remain single spaces.
Примеры
Ввод
"Let's take LeetCode contest"Вывод
"s'teL ekat edoCteeL tsetnoc"Ввод
"God Ding"Вывод
"doG gniD"Ввод
"abc"Вывод
"cba"Нужно реализовать
def reverse_each_word(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
"Let's take LeetCode contest"Expected
"s'teL ekat edoCteeL tsetnoc"2
Input
"God Ding"Expected
"doG gniD"3
Input
"abc"Expected
"cba"4
Input
"a b c"Expected
"a b c"5
Input
"hello world"Expected
"olleh dlrow"6
Input
"ab"Expected
"ba"Focus radio
Paused · SomaFM · Fluid