# 6.Just weight and see

#1

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

Here is the 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]
}

def average(numbers):
total=sum(numbers)
total=float(total)
def get_average(student):
homework=average(student["homework"])
quizzes=average(student["quizzes"])
tests=average(students["tests"])
summ = 0.1*homework+0.3*quizzes+0.6*tests
return summ

``Replace this line with your code.``

#2

you do not need to create the 'summ' variable, this is my code that works:

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

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

#3

That error message is saying that you are doing something similar to:

``[1, 2, 3]['kebab']``

As it points out, strings can't be used as indexes for a list. Study your code and look for places where you might be doing something like this. You've probably mixed up some variables somewhere, treating them as something other than what they are.
Use print statements to find out what variables refer to rather than guessing.
A good start is to call your function the same way as the error message mentions so that you are reproducing the problem as you're looking at how your code behaves.

#4

Even after omitting the summ variable,the code is pretty much the same and i still get the same error.
Kindly help me figure out wherein lies the problem!

#5

The problem should be something like you mentioned.
Surprisingly,it got resolved on its own without any changes to the code(after coming again to the site after 3 hours or so).
Still,thanks for the support!

#6

Why this code works:

summed = (0.1 * homework) + (0.3 * quizzes) + (0.6 * tests)

and this doesn't ?

summed = sum(0.1 * homework, 0.3 * quizzes, 0.6 * tests)

Likely just because sum function accepts only 2 arguments right ? Or do you have something to add to that ?

#8