1. Lesson Number One


#1



https://www.codecademy.com/courses/python-beginner-en-qzsCL/0/1?curriculum_id=4f89dab3d788890003000096


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


I expect the code should run correctly. What am I missing? Is lloyd a special name in Python?


Replace this line with your code. 
lloyd = {
    "name":"Lloyd",
    "homework": [],
    "quizzes": [],
    "tests": []
    }
    
alice = {
    "name":"Alice"
    "homework": [],
    "quizzes": [],
    "tests": []
    }
    
tyler = {
    "name": "Tyler",
    "homework": [],
    "quizzes": [],
    "tests": []
    }


#2

i find the error in the output window more interesting:

File "python", line 10
"homework": [],
^
SyntaxError: invalid syntax

look at line 9, something is missing.


#4

I see that syntax error as well. Yet, I get the same code “homework”: [] for line 3 and 17 but do not see any syntax error. Why is that?

I do not know what I am missing for “homework”: []. I suppose I put an empty list. Please send me more information or give me a hint. Thanks.


#5

did you look at this line:

"name":"Alice"

like i suggested? Nothing missing? Are you sure?


#7

I retyped my code again and used ’ ’ instead of " “. This somehow works. However, I am still unsure why this happens. I originally had “homework”: [ ] and created the dictionaries with a bracket and a colon. What does the error " invalid syntax” mean in this case? Thank you.

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


#8

now you added the comma after "name":"Alice" to seperate the key value pairs, it was missing before. If you use apostophe or quotation marks doesn’t matter


#9

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