我正在尝试通过 codeacademy 学习 python。任务是制作 3 部字典(为每个学生),然后列出 3 部字典。然后,我应该打印出列表中的所有数据。
我试图以与字典本身相同的方式调用值(lloyd [values]),但随后它说未定义值 o_O。我也尝试过“打印名称”,但错误消息是我没有打印出其中一个值。
非常感谢您的帮助。
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]
}
students = [lloyd, alice, tyler]
for names in students:
print lloyd[values]