dimanche 31 juillet 2016

Find the maximum sum of list values in dictionary

I need help trying to find the student who has the highest total scores.

s1= {'A': [100, 95, 100], 'B': [100, 100, 100], 'C': [95, 95, 80], 'D': [100, 100, 80]}
def wrtd2():
  for k, v in s1.iteritems():
     total = 0
     for i in v:
      total = total + i
     print total

wrtd2()

But it is printing the total for all students.

Aucun commentaire:

Enregistrer un commentaire