Reverse Words
Reverse WordsWrite a function, word_reverser()
, that will take a given string and reverse the order of the words. You may assume that the string is a sentence that contains only letters and spaces, with all words separated by one space.
For example, word_reverser("Codecademy rules")
should return "rules Codecademy"
and word_reverser("May the Fourth be with you")
should return "you with be Fourth the May"
.
This challenge was reported to have been asked at interviews with Facebook and Google. If you’ve covered the material in Pass the Technical Interview with Python or an equivalent, you should be able to solve this challenge. If you have trouble, try refreshing your knowledge there first.