You successfully pass i by name.
fl=[lambda x: x**i for i in range(5)]
Each time lambda is executed, it associates the same function i with the function, so when the function is executed (later), it uses the current value of i (which will be 4). Instead, you should pass it as the default argument:
fl=[lambda x, j=i: x**j for i in range(5)]
Actually, I noticed that you are abusing partial . Here:
fl = [partial(lambda x, y: y ** x, i) for i in range(5)]
This also works.
source share