Home My space log
Language EN (English)

Reverse the words

Python Intermediate alien ages 11-13

The problem

Write a function reverse_words(sentence). It gives back the same words in the opposite order, joined by single spaces. Example: "one two three" becomes "three two one". Extra spaces at the ends or in the middle are ignored.

You will practice: strings, split and join, slicing

Mode

Press Tab to indent. Press Esc and then Tab to move on to the next button.

Your code runs in your browser. We do not receive it or save it. Python is downloaded from cdn.jsdelivr.net the first time you run it (about 10 MB).

Test results

      What your code printed