0

I created a list of lambda functions, and later called these functions in the list. However, they call the very last lambda only. I cannot see what the lambda is, in order to check it, since all it returns is a signature like <function <lambda> at 0x7f6da69b89e0>. Unless Python doesn't allow a list consisting of lambda functions? I am using Python 3.

quxs = [2, 3, 5, 7]
funs = []
for qux in quxs:
    funs.append (lambda x, y: x + y * qux)
for fun in funs:
    print (fun (1, 4))

# expected: 9, 13, 21, 29
# result: 29, 29, 29, 29
Violapterin
  • 337
  • 2
  • 14

0 Answers0