Tuesday, 20 September 2016

Orangecap IPL

Define a Python function "orangecap(d)" that reads a dictionary d of this form and identifies the player with the highest total score.  Your function should return a pair (playername,topscore) where playername is a string, the name of the player with the highest score, and topscore is an integer, the total score of playername.



def orangecap(d):
    d2={}
    for p in d:
        for q in d[p]:
            d2[q] = d2.get(q, 0) + d[p][q]
    name = max(d2, key=d2.get)

    return name, d2[name]

No comments:

Post a Comment