Python is a lazy language, so the i in your lambda will not be evaluated until you print it. At that point the loop is finished and i kept the last value 3
.
To get your wanted output, use lambda i=i: i
. This will create an i variable local to each lambda and assign the current i value to it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…