4. For the record - Rejected good solution?


I don't get why it does not accept my solution since it seems to be good for me. (Checked many times on the console but its correct.)

So my code is okay but the site does not accept it.

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


If the instructions are to print homework, then what they mean is to print the single value that represents the homework for a student, not iterate through it and print each element on its own.


Instructions are the following:

for each student in your students list, print out that student's data, as follows:

print the student's name
print the student's homework
print the student's quizzes
print the student's tests

Based on it i think i have to print out all data for all students in this order.


Okay, got it.

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

It was more simple than i expected. :smiley:


my code that 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 mem in students:
print mem["name"]
print mem["homework"]
print mem["quizzes"]
print mem["tests"]


My mistake yes your solution works


is correct, that this works?

`students = [lloyd, alice, tyler]

for names in students:
for key in names:
print names[key]`