# Part of the Whole - error message, but can't see a mistake

#1

Hi,
I keep getting the following error message:
"Oops, try again. get_class_average([alice]) returned 83.8666666667 instead of 91.15 as expected", and earlier I received an error message telling me the output was a letter when it should have been a number

But I've checked my code against other examples on here, and as far as I can see there are no mistakes - please can someone help me? Thank you!

``````lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

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

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

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):
students = [lloyd, alice, tyler]
results = []
for student in students:
results.append(get_average(student))
return average(results)``````

8. Part of the whole get_class_average([alice]) returned 83.8666666667 instead of 91.15
#2

This should be defined in global scope (just after the dictionaries is a good place for it). When the lesson check passes in its own argument, the above line is overwriting the parameter.

#3

Thank you so much, that works now.

#4

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