Just weight and see String instead of interger error

#1

I've tried to work this exercise multiple ways and I'm stuck on this error.
get_average(alice) raised the following error: list indices must be integers, not str
Thank you for any light you may shine on this issue.

``````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]
}
students= [lloyd, alice, tyler]
def average(numbers):
total = sum(numbers)
avg = float(total) / len(numbers)
return avg

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

#2

Hi @whobilly ,

In the `get_average` function, you have this, which attempts to access the global list, `students`, where it should instead access the `student` function parameter ...

``tests = average(students["tests"])``

#3

Right. Thanks for the quick reply.

am I not telling the function to reference the students names with the code above the functions?

students = [lloyd, alice, tyler]

#4

I see now. It was a simple misplaces s

Thank you!

#5

Yes, you have three statements in the `get_average` function where that correction needs to be made. In that function, you need `student` instead of `students`.

Have you gotten it to work?

#6