Lesson One Syntax Error


#1

I keep getting a syntax error and I don't know why. Can anyone help?
lloyd = {
'name': ['Lloyd'],
'homework': [],
'quizzes': [],
'test'
}
alice = {
'name': ['Alice'],
'homework': [],
'quizzes': [],
'test'
}

tyler = {
'name': ['Tyler'],
'homework': [],
'quizzes': [],
'test'
}

File "python", line 6
}
^
SyntaxError: invalid syntax


#2

Python expects value for 'test' key

Add empty array like this:

'test' : []

#3

Ah silly me, I didn't notice that at all. Thank you!


#4

i dont understand whats the problem in this?
it is giving an syntax error?

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


#5

There is no syntax error. I think that you have to read the instructions. They say that each dictionary have the key "tests". You are using "test":

Also I think that the name key must be string instead of array. Try to remove the brackets here:


#6

Thank you dear...!
it worked!

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

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

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


#7

Hi Juliet,
Kind of stuck with the same problem....throwing the following error:

Oops, try again. Your code looks a bit off--it threw a "'set' object has no attribute 'getitem'" error. Feel free to peek back at earlier exercises if you need a syntax refresher!

And this error gets printed on output display:

Traceback (most recent call last):
File "python", line 21, in
TypeError: 'set' object has no attribute 'getitem'

Here is my piece of code:

lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}
students = {"Lloyd", "Alice", "Tyler"}
for student in students:
print students["name"] <-- This is Line 21
print students["homework"]
print students["quizzes"]
print students["tests"]

Regards,
Shahab


#8

You are using strings here:

instead of objects. Use the variables lloyd, alice and tyler (not "Lloyd", "Alice" and "Tyler").
And students must be array - use [ ] brackets.

Also when you are printing the students here:

use student["name"] instead of students["name"]


#9

Thanks so much Julieta. This worked:

Lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
Alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
Tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}
students = [Lloyd, Alice, Tyler]
for student in students:
print student["name"]
print student["homework"]
print student["quizzes"]
print student["tests"]


#10

remove [] !!!
you can not code ['Lloyd']
try change to 'Lloyd'