# How is everybody doing?

#1

Could anyone help me? ... I am stucked with it. I am not understanding what and where I suppose change in my code. There is something that Python is noticing that is string or integer. I really dont get it.

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

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

if type(score) == int:
if score >= 90:
return "A"
elif score >= 80:
return "B"
elif score >= 70:
return "C"
elif score >= 60:
return "D"
else:
return "F"

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

def get_class_average(students):
results = []
for x in students:
results.append(get_average(x))
return average(students)

print get_class_average(students)

This is the error that I am getting:

Traceback (most recent call last):
File "python", line 53, in
File "python", line 50, in get_class_average
File "python", line 27, in get_average
TypeError: string indices must be integers, not str

#2

This is in get_class_average().

I assume that you meant `return average(results)` here. Not sure if there is more.

Edit. :

I think you also need to set the student list to [lloyd, alice, tyler] to make it a list of the dictionaries instead of a list of strings.

#3

def get_class_average(students):
results=[]
for student in students:
results.append(get_average(student))
return average(results)

print get_class_average(students)