Syntax problem in 10. Modifying an element of a list in a function


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/2/3?curriculum_id=4f89dab3d788890003000096

I keep getting an "invalid syntax" message, with the arrow pointing to the equal sign no matter if I write the code
return x[1] += 3
or
return x[1]= x[1]+3

What is wrong with the equal sign??


def list_function(x):
    return x[1] += 3
    return x

n = [3, 5, 7]
print list_function(n)


#2

What you are doing in line return x[1] += 3 is trying to return x[1] = x[1] + 3, which gives you syntax error. You should separate assignment and return.
You should increment the first element of list by 3 and then return the list.


#3

you can't update and return a variable on the same line:

return x[1] += 3

plus, you want to return the whole list. Remove the return from the line where you are updating your list.