4/9 help!


#1

what is wrong with my code
for x in students:
print x['name']
print x['homework']
print x['quizzes']
print x['tests']


#2

for students in students:
print "Student's name: %s" % students["name"]
print "Student's homework: %s" % students["homework"]
print "Student's quizzes: %s" % students["quizzes"]
print "Student's tests: %s" % students["tests"


#3

What about the indents


#4

lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}


#5

You should use code like this :

students = [lloyd, alice, tyler]
for student in students:
print student["name"]
print student["homework"]
print student["quizzes"]
print student["tests"]


#6

Can I ask why do we use
student
and not
students
at the print part?


#7

I used students, its the name of the list you are referring to


#8
for student in students:
    print student["name"]
    print student["homework"]
    print student["quizzes"]
    print student["tests"]

#9

agree. indentation is important in python.


#10

Why is it that when we run

for student in students:
    print student["name"]
    print student["homework"]
    print student["quizzes"]
    print student["tests"]

it gives us the desired output, but when we run

for *anything except for 'student'* in students:
    print student["name"]
    print student["homework"]
    print student["quizzes"]
    print student["tests"]

We get Tyler's grades printed out three times?


#11

i've never seen "anything except for"


#12

The choice of using "student" and "students" in the for loop definition makes it a little confusing, however bear in mind that "student" represents the number of iterations while "students" is the actual list name. We are running our loop against the number of iterations which in this case is "student". Replace "student" with "X" and it might make more sense.
students = [lloyd, alice, tyler]
for X in students:
print X["name"]
print X["homework"]
print X["quizzes"]
print X["tests"]


#13

Hey, you missed the last brace, I was wracking my brain over what I was missing

next time bro/sis, be careful

~Phoenix~