I am stuck with this question, can you solve the challenge? Here we go!
We represent scores of players across a sequence of matches in a two level dictionary as follows:
You can easily use a running counter to count the scores first:
from collections import Counter
def orangecap(d):
total = Counter()
for match_result in d.values():
total.update(match_result)
return total.most_common(1)[0]
Here Counter.update(iterable) will increment the counters for the players mentioned. Counter.most_common(n) specifies we want the first most common element. This will return a list and we pick the first tuple.
>>> orangecap(d)
('player3', 100)