logo CodeStepByStep logo


Language/Type: Python string return

Write a function named reverse_word_order that accepts a string s as its parameter and returns a new string with the words from s in reverse order. A word is a sequence of one or more non-space characters; words are separated by single spaces. For example, the call of reverse_word_order("Hello what is your name?") should return "name? your is what Hello".

This problem is fairly straightforward to solve if you use the string function split. For added challenge, can you solve it without using split?

Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.