For the record;It's not a good way,Help


#1

Help,i think this is not a perfect way to do it,…

**inttoductions:**
for each student in your students list, print out that student's data, as follows:

print the student's name
print the student's homework
print the student's quizzes
print the student's 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]
}
students = [lloyd,alice,tyler]
print students[0][“name”]
print students[0][“homework”]
print students[0][“quizzes”]
print students[0][“tests”]
print students[1][“name”]
print students[1][“homework”]
print students[1][“quizzes”]
print students[1][“tests”]
print students[2][“name”]
print students[2][“homework”]
print students[2][“quizzes”]
print students[2][“tests”]


#2

Each dictionary object has the same keys, which should give us an idea of how to iterate over them. Pick a dictionary reference from a list…

for student in students:

We know that student will be an individual dictionary. Now we can print the keys and data in any order we wish…

    print student['name']
    print ...

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.