This is what we want to get, as a python test:
def test_provided_1(self): self.assertEqual('World Hello', solution('Hello World'))And the core of the solution is a mere one-liner:
' '.join(reversed(line.split()))We split the line, getting a list of strings, reverse it, and join the result on a blank.
I pushed the complete python script, and even the associated unit test, to GitHub.
No comments:
Post a Comment