The following is the code I found in a learning website.
callables = []
for i in (1, 2, 3):
callables.append(lambda a=i: a)
for f in callables:
print(f())
Why can we not print the callables list with just
print(callables)
If i do print(callables) instead, I get the output as follows:
[<function at 0x0000022DA8185760>, <function at 0x0000022DA81851C0>, <function at 0x0000022DA81EB2E0>]
New contributor
Sujitha A is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.