DML School of Technology
Menu

Getting going, Strings

Words backwards

The task

Return the sentence with its words in reverse order (the letters in each word stay as they are). Words are separated by single spaces.

Write a function called reverse_words.

Tests

CallExpectedYours
reverse_words('I love Lagos') 'Lagos love I' not run
reverse_words('one') 'one' not run
reverse_words('code every day') 'day every code' not run

Next challenge · All challenges

solution.py

Tab indents. To leave the editor, press Escape, then Tab.

Output

Run prints what your code prints. Run the tests to check your function.