Skip to content

Latest commit

 

History

History
41 lines (23 loc) · 574 Bytes

Reversed_Words.md

File metadata and controls

41 lines (23 loc) · 574 Bytes

CodeWars Python Solutions


Reversed Words

Complete the solution so that it reverses all of the words within the string passed in.

Examples:

reverseWords("The greatest victory is that which requires no battle")
# should return "battle no requires which that is victory greatest The"

Given Code

def reverseWords(str):
    pass

Solution

def reverseWords(str):
    return " ".join(w for w in str.split()[::-1])

See on CodeWars.com