4. For the Record


#1

Error : Did you print out each student's name? It looks like "Lloyd" wasn't printed.

The output looks fine. I don't know why there is an error.

MY CODES :

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: %s" % student["name"]
print "Homework: %s" % str(student["homework"])
print "Quizzes: %s" % str(student["quizzes"])
print "Tests: %s" % str(student["tests"])
print ""

OUTPUT :

Name: Lloyd
Homework: [90.0, 97.0, 75.0, 92.0]
Quizzes: [88.0, 40.0, 94.0]
Tests: [75.0, 90.0]

Name: Alice
Homework: [100.0, 92.0, 98.0, 100.0]
Quizzes: [82.0, 83.0, 91.0]
Tests: [89.0, 97.0]

Name: Tyler
Homework: [0.0, 87.0, 75.0, 22.0]
Quizzes: [0.0, 75.0, 78.0]
Tests: [100.0, 100.0]

None


#2

Ok, I found out why. I simplified it and there's no error now.

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


#3

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