# Student Becomes The Teacher 8/9

#1

I was seeing similar errors, but was unable to spot my error in the forums. Can someone help? I am getting that get_class_average([alice,lloyd]) returned 91.15 instead of 85.85 as expected.

def average(numbers):
total = sum(numbers)
total = float(total)
total = total/len(numbers)

student = [lloyd, alice, tyler]

def get_average(student):
homework = average(student[“homework”])
quizzes = average(student[“quizzes”])
tests = average(student[“tests”])
avg = .1homework + .3quizzes + .6*tests
return avg

if score >= 90 :
return "A"
elif score >= 80 :
return "B"
elif score >= 70 :
return "C"
elif score >= 60 :
return "D"
else :
return “F”

def get_class_average(class_list) :
results = []
x=0
for x in range(len(class_list)) :
student_avg = get_average(class_list[x])
results.append(student_avg)
return average(results)

#2

Is that line inside the loop?

#3

Yes. I was under the impression that it should be

#4

Better to let the loop run all its iterations before returning the final result.

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.