Key of max value in a dict
python, python-3.x
Solution
Use the `key=` keyword argument to `max()`:
max(d, key=lambda k: d[k])
Instead of the lambda you can use `operators.itemgetter` as well:
import operators
max(d, key=operators.itemgetter(d))
or pass in `d.get`:
max(d, key=d.get)
Problem
This gives the max value in a dict, but how do I get the dict key for the max value? ``` max([d[i] for i in d]) ```