0

I need to create a list of lambda functions, that call another function with parameters, whose value should be contained in the function.

Instead of containing a fixed value of a parameter, the lambdas seem to contain a link to it

b = [lambda n: n*x for x in [1,2,3,4]]
>>> for func in b:
...     print(func(2))
... 
8
8
8
8

expected output:

2
4
6
8
anton-tsyganenko
  • 147
  • 1
  • 1
  • 8

0 Answers0