# Stuck on 8/9, keep getting different errors

#1

First, here's my code. And indentations were not showing up, so in this post I'm just using the underscores before the text to represent indentations:

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 = sum(numbers)
_ _ total_sum = float(total) / len(numbers)

def get_average(student):
_ _ homework = average(student["homework"])
_ _ quizzes = average(student["quizzes"])
_ _ tests = average(student["tests"])
_ _ student_average = 0.10 * homework + 0.30 * quizzes + 0.60 * tests
_ _ return student_average

_ _ 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:
_ _ _ _ get_average(student)
_ _ _ _ results.append(get_average(student))
_ _ _ _ return results
_ _ average(results)
_ _ return results
_ _ print results

IT's supposed to get the class average for the 3 students. But when I run it, the module gives the error "get_class_average([alice]) should return a number". I can't see how it wouldn't be returning a number. The error should only be in the last part of the code, as it has been working fine on previous modules.

Any help is appreciated!
Mike

#2

You have to pass it a list of the dicts for it to work on, you even have it programmed that way.

``students = [lloyd, alice, tyler]``

then pass your

``def get_class_average(students):``

The list of dicts, I would also change your function parameter so that it does not have the same name as your list.

#3

Thanks, I can't believe that I forgot the list! I got it to work now!