What is the output of the following code?

Category: PythonWhat is the output of the following code?
Editor">Editor Staff asked 2 years ago

What is the output of the following code?

def multipliers():
return [lambda x : i * x for i in range(4)]
print([m(2) for m in multipliers()])

a) [6,6,6,6] 
b) [0,2,4,6]
c) [0,1,2,3]
d) [0,0,0,0]

1 Answers
Editor">Editor Staff answered 2 years ago

a) [6,6,6,6]