106. Python Program to Reverse the Words in a Sentence
MediumSplit and join
Overview
Split, change, join: this time the change is to the order of the words.
Problem Statement
Read a sentence and print its words in reverse order, with exactly one space between them. The letters inside each word stay as they are. For example, for I love Python:
Python love I
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One line of text. Example:
I love Python
Output
The output for that example:
Python love I
The tests try 4 different inputs, including one with extra spaces and one with a single word.