Your question is Reverse Sentence With Word Order. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
An applied AI annotation workflows may receive sentences with inconsistent spacing before they are displayed or evaluated. Given a string, return the sentence with its words in reverse order, separated by exactly one space.
A word is any maximal sequence of non-whitespace characters. Leading, trailing, and repeated whitespace must not appear in the result. Preserve every character within each word, including punctuation, digits, and symbols.
Implement reverse_sentence(s), where s is a string. Return a string containing the words from s in reverse order. If s contains no words, return the empty string.
def reverse_sentence(s):