Get the key with the maximum value in a Python dictionary

I run into this task from time to time. So maybe it is better to just write it down here for future reference.

[code language=”python”]
d = {‘a’: 1000, ‘b’: 5000, ‘c’: 2000}
keyWithMaxValue = max(d.iterkeys(), key=(lambda key: d[key]))

Be sure to spell lambda right.