13: How come this version does not also work?


First, let me say that I got the answer using their given code. However, I tried doing this exercise a different way and I am not getting the correct results, and I'm wondering why.

n = [3, 5, 7]

def double_list(x):
    for i in x:
        i *= 2
    return x
print double_list(n)

I thought that i would be each element within the passed list, and i's value would get multiplied by 2. However the list being printed is the same one in the beginning. Can anyone explain why this is?


Hi I think that its because you return x instead of i like that

return i