Good evening.
I have a dict of the following type:
d = {key1: 1, key2: 2}
and I would like to define a corresponding dict of lambda functions as
functions = {key1: (lambda x: 1*x), key2: (lambda y: 2*y)}.
But somehow the following code
functions = {key: (lambda x: value*x) for key, value in d.items()}
is not yielding the desired result, as the functions for both keys are the same. Has someone an idea for a workaround?
Thanks in advance