# 13. Modifying each element in a list function

#1

Receiving the error:

Oops, try again. double_list([0, 1]) returned [0, 1] instead of [0, 2]

Code below:

``````n = [3, 5, 7]

def double_list(x):
for i in range(0, len(x)):
x[i] = x[i] * 2
return x

print double_list(n)``````

#2

Hi, @jordanmich ,

This statement is indented too much, making it part of the `for` loop. The function returns the list, `x`, during the first iteration of the loop, after only the first element has been doubled ...

``return x``

#3

Thanks @appylpye, worked perfectly.

#4

I'm not getting the same answer. Help?

n = [3, 5, 7]

def double_list(x):
....for i in range(0, len(n)):
..........n[i] = n[i] * 2
....return n

print double_list(n)

Oops, try again. double_list([0, 1]) returned [12, 20, 28] instead of [0, 2]

#5

change n for x

ex. for i in range(0, len(x)):

change all n for x

#6

you are meant to change the 'n's for 'x's

#7

Yay! Mine worked , thank you!

#8

'''n = [3, 5, 7]

def double_list(n):
for i in range(0, len(n)):
n[i] = n[i] * 2
return n
print double_list(n)'''

so why did i need x at all ??

#9

Thanks guys, this really helped me because i was stuck on this for weeks

#10