2

I want to make a list of functions using a list comprehension. What I have is the following:

f = [lambda x:x*i for i in range(3)]

As far as I understand f is a list of functions.

Now if I call the first function via:

f[0](100)

I get 300 and also calling the second function f[1](100) I get 300. I don't understand why I don't get 0 in the first call and 100 after my second call.

Vishnu Upadhyay
  • 5,043
  • 1
  • 13
  • 24
user1409534
  • 2,140
  • 4
  • 27
  • 33

0 Answers0