← Back to challenges

Shuffle the Name

PythonHardstringssorting

Instructions

Create a function that takes a string (will be a person's first and last name) and returns a string with the first and last name swapped.

Examples

name_shuffle("Donald Trump") ➞ "Trump Donald"

name_shuffle("Rosie O'Donnell") ➞ "O'Donnell Rosie"

name_shuffle("Seymour Butts") ➞ "Butts Seymour"

Notes

  • There will be exactly one space between the first and last name.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Find the Odd Integer