The following is a code snippet which I don't seem to get. The question is how to make the function output the desired result (not mentioning what the desired result is, I assume its printing 0 to 9).
Here is the question: What does the below code snippet print out? How can we fix the anonymous functions to behave as we'd expect?
functions = []
for i in range(10):
functions.append(lambda : i)
for f in functions:
print(f())