Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:
This is because i is not captured by the function definition. `lambda x: x**i` always makes the "input to the ith power" function, never the "input to the 3rd power" function, even if i happens to be 3 right now. Consider replacing `lambda x: x**i` with `lambda x, i=i: x**i` to explicitly capture the current value of i as a default. Changing the scoping rules now would be a big backwards-incompatible change. ---------- nosy: +Dennis Sweeney _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47028> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com