I tried the following code in Python 3.5.1:
>>> f = {x: (lambda y: x) for x in range(10)}
>>> f[5](3)
9
It's obvious that this should return 5. I don't understand where the other value comes from, and I wasn't able to find anything.
It seems like it's something related to reference - it always returns the answer of f[9], which is the last function assigned.
What's the error here, and how should this be done so that it works properly?