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


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
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)


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.


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.