def list_function(x):

return x[1]= x[1] + 3

n = [3, 5, 7]

print list_function(n)

no idea why this is showing up as wrong. says invalid syntax and points to the equal sign on line 2

def list_function(x):

return x[1]= x[1] + 3

n = [3, 5, 7]

print list_function(n)

no idea why this is showing up as wrong. says invalid syntax and points to the equal sign on line 2

Modifying an element of a list in a function, question

Hi @vital03,

A single statement cannot perform both an assignment and a `return`

at the same time, therefore this is invalid ...

`return x[1]= x[1] + 3`

Instead, have a statement perform the assignment, then follow it with another statement that `return`

s the object that is specified by the instructions.

Thanks, now I'm getting a different error. the console shows 8 coming out but I get pairs of random numbers from the 'oops try again' pop up

here is the new code

def list_function(x):

x[1] = x[1]+3

return x[1]

n = [3, 5, 7]

print list_function(n)

You have this ...

` return x[1]`

... but the instructions state ...

Return the list.

You returned only one element of the list.