Lambda with different expression returns same output

后端 未结 0 442
谎友^
谎友^ 2021-02-04 13:04

Take this code snippet for example:

a = []
for x in range(2):
    a.append(lambda: print(x))
print(a[0](), a[1]())

The output is:

         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题