# Does anyone know how to fix this?

#1

Hi everyone, there's an error here that says: get_class_average([alice, lloyd]) returned 91.15 instead of 85.85 as expected

Does anyone know how to fix this?
Thank you!!

" students = [lloyd, alice, tyler]
def average(numbers):
total = sum(numbers)
total = float(total)
average_student = float(total) / len(numbers)
return average_student

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
weighted = 0.1 * homework + 0.3 * quizzes + 0.6 * tests
return weighted

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(students):
results = []
for student in students:
average_each_student = get_average(student)
results.append(average_each_student)
return average(results) "

Part of the whole
#2

Be sure that the return statement is not inside the loop body.

#3

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