# Did I do wrong with 6/9? It is refreshing for ever

#1

My code for 6/9 is below. When I hit run, it is never runs and just keeps refreshing. Can anyone help to figure out what is wrong with this code, and how can I move on? Is this a bug of the website? Thanks.

In the last part of the code, shouldn’t it be `def get_average(students)` instead of `get_average(student)`? Because in the first line,`students` is a variable.

``````students = ["lloyd", "alice", "tyler"]
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)
result = total / len(numbers)
return result

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

#2

No. The function `get_average()` is averaging one student’s scores for homework, quizzes, and tests. You pass in the student when you call the function like this:

`print get_average(alice)`

There are problems with this function as well. Look at the comments I added and notice that the function returns only the total. Why? Think about it.

`return` exits the function and returns the value to the caller. That means the rest of the code in the `average()` function does not run.

#3

Thanks a lot!! So the correct code for 6/9 should look like below correct? But when I hit run, it still keeps loading and just won’t move on. I have been stuck here all day. Is there a solution to this?

``````students = ["lloyd", "alice", "tyler"]
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)
result = total / len(numbers)
return result

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

#4

Look at this like of code. What do you see that’s wrong?

#5

Uh `homework` ! I fixed it but it seems there’s still something wrong since it won’t stop loading:

``````students = ["lloyd", "alice", "tyler"]
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)
result = total / len(numbers)
return result

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

#6

In Chrome, the lesson continues to spin for me too. I switched to Firefox and no problem. Clearing the browser’s cache cleared out the issue in Chrome for me. Give that a try.

You also have a problem in this line of code. Can you spot it?

Your `students` array is a string of student names in lowercase instead of an array of student objects.

#7

Tried as I might, I can’t solve the problem by switching to Firefox or clearing cache in Chrome. Thank you so much for the advice though! I really appreciate that you checked my code. I wish Codecademy has the option of skipping the current exercise. Otherwise it is difficult to go on when something is wrong with the system.

And this is my final code:

``````students = [lloyd, alice, tyler]
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)
result = total / len(numbers)
return result

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

#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.