# Modifying an element of a list in a function

#1

``````n = [3, 5, 7]
def list_function(x):
for i in range(0, len(x)):
x[i] = x[i] * 2# Don't forget to return your new list!
return x
print list_function(n)``````

``````Oops, try again. list_function([5, 0]) returned [10, 0] instead of [5, 3]
[6, 10, 14]
None``````

#2

I do not have a clue what is going on here. I keep on getting an error message.

#3

this exercise:

uhm... all you need to do is modify one item in the list? no need for a loop. please read the instructions

#4

I forgot about that! but I will do

#5

It doesn't make sense to me...

#6

What am I missing in the instructions that makes it wrong?

#7

you need update the item on index 1 (the second item in the list), for example:

``````y = [5,12,3]
y[0] = y[0] + 28``````

but then inside the function. just make sure to: select the right index, and add the right amount

#8

It says the same error message

#9

of course it does, i use different values to prevent you from just copy pasting, i was just demonstrating what you should do

#10

I didn't copy paste. I dont know how thta quote got there

#11

can you post an updated version of your code?

#12

``````n = [3, 5, 7]
n[3] = y[5] + 7
def list_function(x):
for i in range(0, len(x)):
x[i] = x[i] * 2# Don't forget to return your new list!
return x
print list_function(n)``````

#13

I do not know what is wrong!

#14

Is it this??? maybe this?

#15

all you need to is update one item in the list:

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

look for `value` in the instructions

#16

`````` File "python", line 6
SyntaxError: 'return' outside function

``````

#17

just a question,,, would this work if I coded this?

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

#18

yes, that should work

#19

okay thank-you STETIN94!

#20