The name key does not have the value "Lloyd" in your lloyd dictionary


#1

A brief search in the forum showed that the error message is produced because of brackets around "Lloyd", i.e lloyd = {"name" = ["Lloyd"], ...}, but I don't have brackets in mine yet the error message persists. Any suggestion is greatly appreciated~


lloyd = {
    "name": "Lloyd",
    "homework": [],
    "quizzes": [],
    "tests": []}
print lloyd["name"]

alice = lloyd
alice["name"] = "Alice"

tyler = lloyd
tyler["name"] = "Tyler"


#2

Changed the code to the following and it worked. Still confused as to why my original code doesn't.

lloyd = {
    "name": "Lloyd",
    "homework": [],
    "quizzes": [],
    "tests": []
}
alice = {
    "name": "Alice",
    "homework": [],
    "quizzes": [],
    "tests": []
}
tyler = {
    "name": "Tyler",
    "homework": [],
    "quizzes": [],
    "tests": []
}

#3

Hello

lloyd = {

"name": "Lloyd",
"homework": [],
"quizzes": [],
"tests": [],

}

This is one dictionary.
You have to make two more for Alice and Tyler.
Also the instructions do not require you to print yet.
I hope that helps.


#4

Does it make sense now?
You had to make 3 dictionaries, for each student, with certain keys.


#5

I was having the same "Lloyd" not in your dictionary.

Code looked like this below, but it still didn't work.

Anyways, I just reset code, re-entered the same code, and it worked.

lloyd = {
"name": "Lloyd",
"homework": [],
"quizzes": [],
"tests":[],
}


#6

Can someone explain why the square brackets are removed for single items in a dictionary. I was having the same problem as above, and only realised to remove [ ] from around "Lloyd" after seeing this post. I thought all items in a dictionary are surrounded by brackets.
Thanks.


#7

I think the indentation was the issue there.
All the items in the dictionary should be indented (4 spaces, I believe, or a tab)
I hope that helps!


#8

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