a = [] a.append(lambda x:x**0)
a.append(lambda x:x**1)
a[0](2), a[1](2), a[2](2)... spits out 1, 2, 4, ...
b=[]
for i in range(4)
b.append(lambda x:x**i)
b[0](2), b[1](2), b[2](2)... spits out 8, 8, 8, ...
In the for loop, I pass lambda as a variable, so when I call it, the last value I use instead of code that executes the same way as with []. (ie b [0] should use x ^ 1, b [1] should use x ^ 2, ...)
How can I tell lambda to select i instead of i itself.
source
share