13. Modifying each element in a list in a function


n = [3, 5, 7]

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)

i am having problem with my code and can't get past questions 13 for lists and functions


Too much indentation on the return line. Back it off by four spaces so it is outside of the for loop.


You need to understand the logic of the code and also the usage of indentation. The way you have written return x, it will return all the result of the immediate above statement. But in this case we need x as a list not by each entity which actually your code is doing.