4. For the record


#1

Ok, i need some syntax master. With my code looking like this:

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]

print (students)

Error says:
Oops, try again. Did you print out each student's name? It looks like "Lloyd" wasn't printed.
It is printed, but not in the order i want it to.

Here is the outcome:
[{'quizzes': [88.0, 40.0, 94.0], 'tests': [75.0, 90.0], 'name': 'Lloyd', 'homework': [90.0, 97.0, 75.0, 92.0]}, {'quizzes': [82.0, 83.0, 91.0], 'tests': [89.0, 97.0], 'name': 'Alice', 'homework': [100.0, 92.0, 98.0, 100.0]}, {'quizzes': [0.0, 75.0, 78.0], 'tests': [100.0, 100.0], 'name': 'Tyler', 'homework': [0.0, 87.0, 75.0, 22.0]}]
None

Why code is not printing the students list, as it is given? It prints argumentsin the reverse alphabetical.


#2

from the instructions:

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

for is a pretty big hint that you need to use a for loop


#3

ok thanks for the help mate


#4

did you solve it with so little help? Really impressive :slight_smile:


#5

hey i put the for statement and then try to print. it still doesnot work


#6

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


#7

this topic is for helping blogrunner14934, if you have a question go here, press the new topic button, feel in the template and someone will help you :slight_smile:

the dictionary keys should be strings, otherwise they are undefined variables


#8

sorry. got it. thanks anyways


#9