This question already has an answer here:
Given a dictionary d
where the key values pair consist of a string as key and an integer as value, I want to print the key string where the value is the maximum.
Of course I can loop over d.items()
, store the maximum and its key and output the latter after the for
loop. But is there a more "pythonic" way just using just a max
function construct like
print max(...)
or even shorter (from comment):