Modifying each element in a list in a function


#1



what is wrong...
I keep getting the error message:
Oops, try again. double_list([0, 1]) returned [0, 1] instead of [0, 2]
Also the editor shows [6, 5, 7] even though it is supposed to show each element multiplied by two:
[6, 10, 14]
I know I am only multiplying n[0] but what do I need to change to get each element * 2
Here is my code:


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

print double_list(n)


#2

It's returning on the first iteration so never gets to the 1.


#3

I still don't get it.
What am I supposed to return?

Thanks for your help


#4

You are returning the correct object, but the indentation is incorrect. Move the return line four spaces to the left.


#5

Thanks! I've had the same - it worked!


#7