Student Becomes the Teacher


#1

I have written expected code for this exercise and got an expected output as well. Still I am receiving below error msg which is stopping me to continue the next chapter. Could any one please help me out here...

Program
for stud in student:
for task in stud:
if (task == "homework"):
homework = 0.1*average(stud["homework"])
elif (task == "quizzes"):
quizzes = 0.3*average(task)
else:
tests = 0.6*average(task)
print sum([homework,quizzes,tests])

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]
}

student = {}
def average(numbers):
total = sum(numbers)
return (total / len(numbers))

def get_average(student):
for stud in student:
homework = 0.1*average(stud["homework"])
quizzes = 0.3*average(stud["quizzes"])
tests = 0.6*average(stud["tests"])
print sum([homework,quizzes,tests])

student = [lloyd,tyler,alice]
get_average(student)

Output:
80.55
79.9
91.15
None

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


#2

Please add the problematic code to your post.