Student teacher #11 please help


here is the code i have:

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 "name"
print "homework"
print "quizzes"
print "tests"

here is the output:

Traceback (most recent call last):
File "python", line 23, in
NameError: name 'name' is not defined

and here is the codecademy™ error:

Oops, try again. Your code looks a bit off--it threw a "name 'name' is not defined" error. Feel free to peek back at earlier exercises if you need a syntax refresher!

if anyone can point me in the right direction here, that would be greatly appreciated!


Look at how the example does it:

animal_sounds = {
    "cat": ["meow", "purr"],
    "dog": ["woof", "bark"],
    "fox": [],
print animal_sounds["cat"]

it puts the dictionary name, uses bracket notation, and then inside of the brackets has the key.
You would want it to look like this:

print student["name"]

The same for homework, quizzes, and tests.


I tried this but it doesn't work for me. My code is as under:

students = [lloyd, alice, tyler]
print students

print students["name"]
print students["homework"]
print students["quizzes"]
print students["tests"]

I keep getting the error: "TypeError: list indices must be integers, not str"


that is because all your students need to be just student :smiley: and @kyleaw has it all correct below. Figured I let you finish what you started stead of me stealing your glory :stuck_out_tongue:


@nishantshastry, along with what @bibleman13 is saying, (he's right), you also need a for each loop. Though he has the correct idea, you whatever variable name you use for your for each loop is what would be outside of the brackets. So if you said

for student in students:

then bibleman13 is correct, but if your for loop looked something like

for x in students:

then inside the functions, your print lines would look like

print x["name"]

I hope this helps!

@bibleman13 steal my glory all you want!


students = [lloyd,alice,tyler]

print get_class_average(students)
print get_letter_grade((get_class_average(students)))