# 13. Modifying each element in a list function-Oops, try again. double_list([0, 1]) resulted in an error: list index out of range

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
13 Modifying each element in list function
<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>
Expect it to work

```python

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

``<do not remove the three backticks above>``

Your list has no variable name.

It does, It just disappeared in copying

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

Oops, try again. double_list([0, 1]) resulted in an error: list index out of range

Here, instead of len(n)) use x. so,

`for i in range(0, len(x)):`

7 Likes

Thanks! I knew it was something stupid I had just forgot

1 Like

you’re welcome 1 Like

@bandit @rootjr def list_function(x):
return x

n = [3, 5, 7]
def double_list(x):
for i in range(0, len(x)):
x[i] = x[i] + 3 OR * 2 <-------
return x
print double_list(n)
print list_function(n)

Change list_function so that:

Add 3 to the item at index one of the list.
Store the result back into index one.
Return the list. what am i doing wrong, did they change this lesson because everyones cose multiplies by two instead of adding 3 im confused

What are you trying to do with this line?