Skip to content

Latest commit

 

History

History

01-05 Sentence Reversal

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Sentence Reversal

Problem

Given a string of words, reverse all the words. For example:

Given:

'This is the best'

Return:

'best the is This'

As part of this exercise you should remove all leading and trailing whitespace. So that inputs such as:

' space here'

and

'space here '

both become:

'here space'

Code

Create your solution in the form:

def rev_word(s: str) -> str:
    pass

Examples

>>> rev_word('Hi John,   are you ready to go?')
'go? to ready you are John, Hi'
>>> rev_word('    space before')
'before space'