(6) Student becomes teacher 1/9


#1

I'm kind of stuck on this question. When I submit the code it says:
Oops, try again. The name key does not have the value "Lloyd" in your lloyd dictionary.

I'm not very sure about where I have made a mistake, it would be great if someone could explain it.

Here is my code:

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

#2

lloyd['name'] should evaluate to 'Lloyd' - try printing the result of that expression and see what's different


#3

lose the []
it should be like this:

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


#4

That seems to have worked, thanks. But now it says that the rest of my keys have invalid syntax​:sweat_smile:


#5

This did not work..,......


#6

try to copy/paste the exact code!


#7

try writing the code on separate lines!


#8

I tried, but it's still not working​:disappointed_relieved:
Still, thank you for trying to help


#10

can you post an updated version of your full code?


#11

Here it is:

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

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

#12

the important word here is evaluate, lets go back to your orignal code:

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

what @ionatan said is that lloyd['name'] should evaluate to "Lloyd", lets see:

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

this evaluate to ["Lloyd"], it should evaluate to "Lloyd"

What you missed is that lloyd['name'] is using a key to retrieve a value from a dictionary, not defining key and value in a dictionary


#13

I see now, thank you.
But what should I do to make it evaluate to "Lloyd" ? ( Because I have currently printed out ['Lloyd'] )


#14

that is the question, how do you think you can achieve this? think data type


#15

I've been stuck on it for some time now, but I will do my best. Thanks again for the help :blush:


#16

Just "name": "Lloyd" ?


#17

@fernandojs is right, the value of name key should be a string, not a list


#18

Yes that works ! I can't believe I made such a ridiculous error​:sweat_smile:


#19

2 posts were split to a new topic: 6. students become teachers


#20

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