I started learning python 3.3 lately, and I'm currently playing with the different features. I tried the following:
L = [lambda x: x*i for i in range(3)]
And I expected it to return a list of 3 functions - the first one gets a number and returns 0, the second one gets a number and returns the same number itself, and third one gets a number x and returns 2x. Apparently all the functions in the list L returns 2x:
>>>L[0](4)
8
>>>L[1](-7)
-14
>>>L[2](3)
6
What am I missing? How is it different from:
L = [lambda x: x*0, lambda x: x*1, lambda x: x*2]
which works as expected?