logo

Name Shuffler

Write a function that returns a string in which firstname is swapped with last name.


My code:

def name_shuffler(str_):
    names = str_.split()
    return names[1] + " " + names[0]

def name_shuffler(str_):
    return ' '.join(str_.split(' ')[::-1])
                                                                
                    


And that's the best solution among all users:

def name_shuffler(str_):
    return ' '.join(str_.split(' ')[::-1])