# Student Becomes the Teacher - Part of the Whole issues

#1

HALP. I have no idea what I'm getting wrong!

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

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

if score >= 90.0:
return "A"
elif 80.0 <= score < 90.0:
return "B"
elif 70.0 <= score < 80.0:
return "C"
elif 60.0 <= score < 70.0:
return "D"
else:
return "F"

def get_class_average(students):
classroom = [lloyd, alice, tyler]
results = []
for student in classroom:
results.append(get_average(student))
return average(results)``````

It's returning the following error:

``````Oops, try again.
get_class_average([alice]) returned 83.8666666667 instead of 91.15 as expected``````

Whyy?

#2

why did you define the classroom inside the function , also you iterate for each student in classroom ??

#3

I didn't do it for any reason in particular, just went following the instructions, and it ended up like that.

For each student item in the class list, calculate get_average(student) and then call results.append() with that result.

So I just followed along with what it requested to do.

#4

yes i know , but you wanna use this function for every classroom , not a single classroom how has lloyd, alice, tyler
so the instruction tell to iterate for each student in class; ( the class is a list of students )
and the list of students you entered to the function is `students`

our code will be :
`for student in students:`

#5

Oh, wow, okay, thank you, that actually went through without any trouble.

Thank you very much!