Find the lambda expression that interprets this python

ask how the variables of the expression change, and how the results, especially n, change.
fun = [(lambda n: i + n) for i in range (10)]

Mar.24,2021

this is one of the few "strange things" in python

fun = [(lambda n: i+n) for i in range(10)]
-sharp 
fun = [(lambda n: 9+n) for _ in range(10)]

because the parameter I in lambda is determined at run time, not at declaration time.

finally fun saves an array of 10 elements, each of which is a lambda method, which is equal to the following lambda_item function

def lambda_item(n):
    return 9 + n

if the entire expression is interpreted in python code, it can be like this

fun = []
for i in range(10):
    fun.append((lambda n: 9+n))
< hr >

another thing that confuses newcomers is

a = [[0]] * 3
a[0].append(1)
print(a)

print out

[[0,1], [0,1], [0,1]]

first of all, I would like to thank @ Li Yi for his answer. His answer is very good.

1, first execution

so, what is the result of this program?

-sharp fun = [(lambda n : i + n) for i in range(10)] 
funs = []
tmp = 0
fun = lambda n: tmp + n
for i in range(10):
  funs.append(fun)
  tmp = i
Menu