| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/https-github-com-nzysoft/Python-2/master/strings/reverse_words.py | [Back] [Original] |
def reverse_words(input_str: str) -> str:
"""
Reverses words in a given string
>>> reverse_words("I love Python")
'Python love I'
>>> reverse_words("I Love Python")
'Python Love I'
"""
return " ".join(input_str.split()[::-1])
if __name__ == "__main__":
import doctest
doctest.testmod()
| Web Proxy Viewer | New URL | Original Page |