Reverse whitespace-delimited words
Return the words of text in reverse order, joined by one space. Discard leading, trailing and repeated whitespace.
words = ' a\tb c '.split()
print(words[::-1])Reason about the state
Split without an explicit separator to normalize whitespace. Reverse the word list and join it once. Before writing code, identify what each variable means after one iteration. Walk through the example and explain why the next transition preserves that meaning. Then check the smallest permitted input and a case with repeated values. A correct answer follows the contract for every input, including the boundary cases in the checks. Keep any input mutation within the stated rules; return a fresh result when the task asks for one.
Your task
Return the words of text in reverse order, joined by one space. Discard leading, trailing and repeated whitespace.
The explanation opens here once every check passes.