For the record: avoiding repetition


#1

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

I have this but how do I keep from having to type "student" so much? I tried

print student["name", "homework", "quizzes", "tests"]

but that doesn't work.


#2

@jareddygert: You actually are avoiding repetition. Consider the alternative: You could write a separate set of print statements for each individual student. Instead, the for loop lets you just cover that with one set of print statements. If you just wanted to print all the student info at once, you could say:

for student in students:
    print student

But since that's not what these instructions required, you're making the exercise as brief as possible.


#3

That makes sense! Thanks


#4

i tried "for student in students". it gives me an error.