I keep getting this error despite following the instructions


#1

I keep getting a "Oops, try again. double_list([0, 1]) returned [0, 1] instead of [0, 2]" message despite following the hint (that pretty much says to put the code from lines 3 - 5 in a def/function).

Here is the code i am using:

n = [3, 5, 7]

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

-comment- Don't forget to return your new list!

print double_list(n)

And here is the original code:

n = [3, 5, 7]

for i in range(0, len(n)):
n[i] = n[i] * 2

Don't forget to return your new list!

print double_list(n)


#2

It is difficult to tell where you have indented, but if you return x inside the for loop - then the first time it goes through the loop it is going to return the input array. So, if x = [0,1] (which i think is a test code academy runs through), then for i = 0, x[0] = 0 *2 = 0 and then code returns x. try pulling the return x line outside the for loop, but still inside the function.

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


#3

I don't know how, but what you posted made the code work. I placed two spaces/[tab] behind the "return x" part.


#4

thanks kind man for good describing of ours mistakes. I got my lesson! Damn.. i have to be more clear with details...