Lesson Number 1 - 1/9


#1

I'm really confused as to why this code won't work. Here's my code:

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

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

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

The error message is:
"Oops, try again. Did you create a dictionary named lloyd? Your code threw a "global name 'lloyd' is not defined" error."

Is this a bug or...?


#2

Nevermind, figured it out!


#3

What was wrong with your code? I'm getting the same error as you.


#4

2 posts were split to a new topic: Problem in Python dictionaries


#6

I am still having the same problem.

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

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

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

print tyler["name"]

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


#7

add colons, mathematical brackets and remove the commas from the last line of the dictionaries like so:
lloyd = {
"name" : ["Lloyd"],
"homework" : [],
"quizzes" : [],
"tests" :[]
}

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

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


#8

3 posts were split to a new topic: Oops, try again. The name key does not have the value "Lloyd" in your lloyd dictionary


#11

Got it to work thanks all!


#12
 It work!  Big thanks!

#13

Apparently I wasn't the only one to miss this fact! (Or was it even mentioned in the dictionaries lesson?)
Thanks!


#14

lloyd, alice, tyler={ } it will create dictionaries

homework [], quizzess[],tests[], this will for later

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

This code is working file


#15

how did you figure this one out? I've been stuck on this problem for a cpl days now and I'm starting to pull my hair out here,


#16

2 posts were split to a new topic: Did you create a dictionary named lloyd? Your code threw a "global name 'lloyd' is not defined" error


#18

Hi you all ! this worked to me :


#19

Closing this topic because of too much users piling up their problem and the thread becoming unbearably long and having lost focus. The original poster's problem has been solved, and there's no point in reviving a two month old thread's activity.

Kindly use a new thread for your problem.

Thanks! :smile: