Spin the Long Words
Imagine a text filter that leaves short words alone but makes longer words look a little more mysterious. Write spin_words so that, in the string sentence, every word with 5 or more characters is reversed. Words are separated by spaces, and the original word order must stay the same.
Примеры
Ввод
"Hey fellow warriors"Вывод
"Hey wollef sroirraw"Ввод
"This is a test"Вывод
"This is a test"Ввод
"This is another test"Вывод
"This is rehtona test"Нужно реализовать
def spin_words(sentence: str) -> str:
Теги
strings
Connectez-vous pour voir l'historique des soumissions
Se connecterConnectez-vous pour utiliser le Mentor IA
Se connecterVisible tests
1
Input
"Hey fellow warriors"Expected
"Hey wollef sroirraw"2
Input
"This is a test"Expected
"This is a test"3
Input
"This is another test"Expected
"This is rehtona test"4
Input
"Welcome"Expected
"emocleW"5
Input
"abcde"Expected
"edcba"6
Input
"HEY FELLOW WARRIORS"Expected
"HEY WOLLEF SROIRRAW"Focus radio
Paused · SomaFM · Fluid