1 2 3 4 5 6
from collections import defaultdict def max_aggregate(stdata): temp = defaultdict(int) for name, marks in stdata: temp[name] += marks return max(temp.items(), key=lambda x: x[1])