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
  • 4,979
  • 1
  • 12
  • 26
user1409534
  • 1,990
  • 2
  • 24
  • 29

0 Answers0