Why do I get this particular error message?



Error : Oops, try again. Did you print out each student's name? It looks like "Lloyd" wasn't printed.

It shows this error. While if I print each entry of the dict separately under the for loop, it doesn't show any error.
What is the difference between printing the entire directory together and printing each entry separately?

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 student in students:
    print student


By doing that,You are printing dictionaries.
Don't forget that alice,tyler and lloyd are dictionaries that have many information inside them.

To access different information (name,homework etc) from these dictionaries, we will use key.

for example to access name..

for student in students:
    print student["name"]

You have to print other things too as mentioned in instructions.


Say if I have to print all the information in a directory. What method should I use?
Do I print each key separately or do I just print the directory by calling it by its name?
What difference is there between the two?


To access dictionary's information we simply use key..we already learnt how to access values using keys from a dictionary.

Like here I used "name" key to access the value associated to "name" key,
same way, to access other information we simply pass the keys..


We see that our dictionaries alice, lloyd and tyler have keys:
"name","homework","quizzes", and "tests"


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