I wanted to create a list of lambdas, but it didn't quite work out as I hoped.
L = [(lambda x: x/y) for y in range(10)]
I expected every function in the list to divide its argument by its index, but all functions only divide by the last index.
>>> L[1](5)
0.5555555555555556
>>> L[5](5)
0.5555555555555556
>>> 5/9
0.5555555555555556
Is this kind of list comprehension, where every lambda has its own copy of y
possible in Python?