A release-notes tool shows the newest component first. Given a sentence, return the words in reverse order, separated by single spaces.
Words are separated by one or more spaces; leading and trailing spaces are ignored.
Implement reverse_words. Input: sentence: str. Returns: str — the words in reverse order joined by one space.
Four words, last first.
def reverse_words(sentence: str) -> str:
# Split the sentence into words, reverse them, join them back.
pass
Run executes the public tests. Submit grades against public and hidden tests.
A release-notes tool shows the newest component first. Given a sentence, return the words in reverse order, separated by single spaces.
Words are separated by one or more spaces; leading and trailing spaces are ignored.
Implement reverse_words. Input: sentence: str. Returns: str — the words in reverse order joined by one space.
Four words, last first.
def reverse_words(sentence: str) -> str:
# Split the sentence into words, reverse them, join them back.
pass
Run executes the public tests. Submit grades against public and hidden tests.