Oops, try again. average([3, 0]) returned 100.0 instead of 1.5 as expected


#1

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(number)
total = float(total)/count
return total
students = [lloyd, alice, tyler]
element = ["homework", "quizzes", "tests"]
c=0
for name in students:
print students[c]["name"]
d=0
for att in element:
att = element[d]
number = students[c][att]
count = len(students[c][att])
result = average(element)
print att[0].upper()+att[1:] +" " + str(result)
d=d+1
c=c+1

This code gives the correct results for all averages etc. but generates what seems to be a silly error message (average 1.5 is nonsensical - 100 is the correct answer for the average0


#2

Check you variable. It does not match the parameter.


#3

Thank you for the insight - I have not completely solved the problem, I now have a slightly different error but I reckon I am on the right path