i need to write a function changeName(name) that takes a string value as an argument. where name is in the form last,first,middle. the function should return a string that has the name in form fits,middle,last.

name1 = input("Enter your name")

def changeName(name):
fields = name.split(",")
return fields
fields = changeName(name1)
print(fields[1],fields[2],fields[0])

thanks what i did but it says it is out of range...

commented: Still no [code] tags! -3

name1 = input("Enter your name")

def changeName(name):
    fields = name.split(",")
    return fields
fields = changeName(name1)
print(fields[1],fields[2],fields[0])

I can not replicate the error, and please uset the code-tags! You did them, I see, but your code is not between them!

Enter your nameVeijalainen, Tony, Jarkko
 Tony  Jarkko Veijalainen

replicating the error is just to organizing the code or fix... dont know why you cant

It functioned, as can be seen log of input and output.

The input has to be in the form last,first,middle. You got to let the user know ...

def changeName(name):
    """
    change name of form last,first,middle to first,middle,last
    """
    fields = name.split(",")
    return fields[1],fields[2],fields[0]

# input has to be in the form last,first,middle
test_name = 'Staub,Joe,P.'
new_name = changeName(test_name)

print(new_name)