I have a code listed below. I am not sure why the returns should be 4
def create_multiplier():
return [lambda x: x*i for i in range(10)]
f = create_multiplier()
print f[1](1)
The result turns out to be 4. I'm familiar with the lambda function something like lambda x: x*2 but very confused about this one. It seems like it get the last iterate of i for example:
for i in range(5):
i
print i