# Just Weight and See - get_average(alice) raised the following error: global name 'sudents' is not defined

#1

I don’t know what to do with this error:
get_average(alice) raised the following error: global name ‘sudents’ is not defined

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

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

is the code I used; I tried adding a “students” list:

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

but that didn’t help

#2

I think you might wanted to use `students` here instead of `sudents`. That together with this:[quote=“anders.exe, post:1, topic:33821”]
is the code I used; I tried adding a “students” list:

students = [lloyd, alice, tyler]
[/quote]

should solve it.

#3

that fixed one problem, but now it’s saying

get_average(alice) raised the following error: list indices must be integers, not str

so I think I need to remove the double quotation marks

#4

There is no think, only try.

#5

did that, now it says

get_average(alice) raised the following error: local variable ‘homework’ referenced before assignment

#6

For indexing (between brackets ), you still need the quotation marks.

#7

now it’s back to “list indicies must be integers, not str”

#8

That’s because you’re calling it on `students`, which is an array. You want to call it on an individual student. You’ll have to think about how to fix that.

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

that works