Key to maxima of dictionary in python -


i have dictionary, "scores", of integers , want find key(s) of highest value. used code:

key = max(scores, key=scores.get) 

however, gives 1 key. how deal ties in highest value? 1 number back. in case of tie? how can keys highest value? help.

you run following, example:

max_value = max(scores.values()) keys = [ (i,v) in scores.iteritems() if v == max_value ] 

"keys" hold keys correspond maximum value.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -