This forum is now read-only. Please use our new forums! Go to forums
banner
Close banner
Confusing error message for 6/9
I’m getting the following error message:
Oops, try again. Did you accidentally delete lloyd, alice, or tyler? Your code threw a “global name ‘lloyd’ is not defined” error.
For the following code:
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]
}
# Add your function below!
def average(lst):
return float(sum(lst) / len(lst)
def get_average(student):
homework_avg = (average(student["homework"]) * .1)
quiz_avg = (average(student["quizzes"]) * .3)
test_avg = (average(student["tests"]) * .6)
weighted_avg = homework_avg + quiz_avg + test_avg
return weighted_avg
I’ve also tried writing the get_average function as a single return statement (doing all the math in one line) and got the same error message.
Can anyone help me?
- List item
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency