I tried to create different functions by the following code:
a = []
for i in range(5):
a.append(lambda: i)
print(a)
and it showed it:
[<function <lambda> at 0x008DA100>, <function <lambda> at 0x008DA0B8>, <function <lambda> at 0x008DA148>, <function <lambda> at 0x008DA190>, <function <lambda> at 0x008DA1D8>]
I found that all the functions are different, but I found that it couldn't work later. Althought all the functions indicated to different address, but all the functions showed same number: 4;
a[0]()
4
a[1]()
4
a[2]()
4
a[3]()
4
a[4]()
4
Please tell me how to solve this problem.