value isn't remembered in lambda python code example
Example: value isn't remembered in lambda python
def main():
d = {}
for x in [1,2]:
d[x] = lambda x=x: print(x)
d[1]()
d[2]()
if __name__ == '__main__':
main()
>>>
1
2