我对字典有一些问题这里是我的代码:
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 (number):
total = 0.0
for i in number:
total = total + number[i]
return total/ len(number)
def get_average(student):
return average(student["homework"])*0.1 + average(student["quizzes"])*0.3 + average(student["tests"])*0.6
print get_average(tyler)
错误: TypeError: list indices must be integers, not float
任何人都可以帮忙吗?