Lesson number one


#1



Oops, try again. The name key does not have the value "Lloyd" in your lloyd dictionary.


This easy piece of code is acting strange. I donot know what to expect.


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

alice = {
    "name" : ["Alice"],
    "homework" :[],
    "quizzes" :[],
    "tests" :[]
    }

tyler = {
    "name" : ["Tyler"],
    "homework" :[],
    "quizzes" :[],
    "tests" :[],
    }


#2

Solved it.

Just needed to remove the bracket for values of name key. Don' t know why though.


#3

I had the same. do you only have the [] for empty dictionary or ones with multiple values ??


#4

Brackets inside of a dictionary means that you are assigning a list to that key. That is why you have brackets on quizzes, homework, and test. You are expecting multiple values to represent the grades in each category. A name, however, will not have multiple values (unless you want to add something like a nickname) and only needs to be a string to be efficient inside the dictionary.

Hope this helps! If not, feel free to leave a reply and I'll try to go more in-depth.


#5

Thank you! This is a very helpful explanation. I wish Code Academy wouldn't leave out helpful bits of information like this.


#9

Why does an empty key "homework" need and empty list [ ] ?
Why doesn't it work like this? (I get an error message)

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


#10

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