4/9 For the Record"It looks like "Lloyd" wasn't printed."


#1

Does anyone know what’s wrong with this 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 “”"
%s
%s
%s
%s""" % (student[“name”], student[“homework”], student[“quizzes”], student[“tests”])

The console log shows:

Lloyd
[90.0, 97.0, 75.0, 92.0]
[88.0, 40.0, 94.0]
[75.0, 90.0]

Alice
[100.0, 92.0, 98.0, 100.0]
[82.0, 83.0, 91.0]
[89.0, 97.0]

Tyler
[0.0, 87.0, 75.0, 22.0]
[0.0, 75.0, 78.0]
[100.0, 100.0]

Thank you!


#2

While the output may look how you wish it to look, the SCT doesn’t see it that way. It sees the docstring where are plain string should appear.

 print "%s\n%r\n%r\n%r" % (student[“name”], student[“homework”], student[“quizzes”], student[“tests”])

might work for your purposes and also satisfy the SCT. If not, then review the instructions again and adjust your code to suit. Please post a link to the lesson so we may verify.


#3

Hello. I looked it up a bit more and found that I was supposed to type print 4 times. It works fine now. Thank you!


#4

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