def weighted_mode(values, weights):
totals = defaultdict(int)<EOL>for v, w in zip(values, weights):<EOL><INDENT>totals[v] += w<EOL><DEDENT>return max(list(totals.keys()), key=totals.get)<EOL>
Return the value with the greatest total weight.
    >>> weighted_mode('abbaa', [1,2,3,1,2])
    'b