Reverse the Word Order

Sometimes you need to reverse the order of words without changing the words themselves, like in simple text formatting. Write reverse_words, which takes a string s containing words separated by single spaces. Return a string with the same words, but in reverse order.

Примеры

Ввод
"hello world"
Вывод
"world hello"
Ввод
"the quick brown fox"
Вывод
"fox brown quick the"
Ввод
"single"
Вывод
"single"

Нужно реализовать

def reverse_words(s: str) -> str:

Теги

stringslists
PostgreSQLv16

Koodin suorituksen tulos näkyy tässä

Visible tests
1
Input
"hello world"
Expected"world hello"
2
Input
"the quick brown fox"
Expected"fox brown quick the"
3
Input
"single"
Expected"single"
4
Input
"a b c d"
Expected"d c b a"
5
Input
""
Expected""
6
Input
"d c b a"
Expected"a b c d"
Focus radio
Paused · SomaFM · Fluid