4. For the Record


#1



Hello guys. We have this 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]
}

students=[lloyd,alice,tyler]

How to print the required information? We have to use a for cicle but I don't know how to print because it is a list of dictionaries.


#2

Fixed, no worries :slight_smile:


#3

Could you explain the solution?


#4

We have the list students=[lloyd,alice,tyler].

We have to set a for cicle for each student and print the information. That means that we have to set 3 for cicle.

The first one is the following:

for x in lloyd:
print lloyd[x]

The other 2 will be the same, just the name will change.


#5

I hope it helped. I am relatively new and I did't realize if I can write the whole code. Please let me know if you need more help.


#6

how to print student data?


#7

for x in lloyd:
print lloyd[x]

for x in alice:
print alice[x]

for x in tyler:
print tyler[x]

Let me know if you solved the issue


#8

To print the student data:

for student in students:
print student["name"]
print student["homework"]
print student["quizzes"]
print student["tests"]

#9

Thanks! I got it now.


#14