if len(specifiers) != 2:
    raise ValueError('Exactly one of year, playerid, teamid, must be given')
ikey, keyv = specifiers[0]
return sum(v[idx] for k, v in stats.items() if k[ikey] == keyv)
Python data structure recommendation?