# 8. Part of the Whole?

#1

Why is my code incorrect, I have tried using different forums and I still have not found an answer.
My error returns: Oops, try again. get_class_average([lloyd]) returned 91.15 instead of 80.55 as expected...
Referring to the passage at the very bottom, that is required to pass this section:

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

``````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(lst):
length = len(lst)
return avg

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

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

def get_class_average(class_list):
for values in students:
return class_average

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

#2

Wait @woo0016,

Why did you have to redeclare `get_class_average` function twice??? One is not enough???

First follow the instruction step by step:

1. Create a function named `get_class_average_student` which takes in parameter `students`.
2. Create an empty list named `results` which will stock the final result.
3. Loop inside `students` list as `student` using for loop.
4. Use the `append` function on `results` which takes in parameter the result of function `get_class_average` that takes in parameter `student`. This thing should be inside for loop.
5. Now, outside the for loop, return list `results`.

Any questions?

#3

It appears that you are redefining your students list and your `get_class_average()` function. Also, make sure to check your indentation. This should help.

``````def get_class_average(students):
results = []
for student in students:
results.append(get_average(student))
return average(results)``````

#4

Sorry, I are potato.