Q:

Write a Python program to calculate the maximum aggregate from the list of tuples (pairs)

0

 Write a Python program to calculate the maximum aggregate from the list of tuples (pairs).

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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


students = [('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)]
print("Original list:")
print(students)
print("\nMaximum aggregate value of the said list of tuple pair:")
print(max_aggregate(students))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now