Error Code on Lesson Number One


#1



Hello! I'm stuck on the very first exercise in this lesson, and I'm not sure where I'm going wrong.


The error that I'm getting from the console is:

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


I don't believe that what I'm doing is incorrect, where am I going wrong?


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

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

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


#2

We use commas to separate key : value pairs.

Are you sure that values of "name" should be arrays?


#3

Okay I fixed that, my code now looks like this:

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

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

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

But I'm getting the error :

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


#4

There are still two missing commas :slight_smile:


#5

Why isn't this right???

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

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

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

#6

Are you sure that values of "name" should be lists? Why?


#7

What do you mean? :confused:


#8

For example, ["Lloyd"] is a list containing a single element - string "Lloyd".

Why have you used a list? Why not just "name": "Lloyd"?


#9

Thanks, wasn't sure what you meant..


#10

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