[Tutor] Something I don't understand

Jim Morcombe jmorcombe at westnet.com.au
Tue Dec 18 02:44:30 CET 2007


Below, "student_seats" is a list of the class "student".

Why does this code set every student.row to zero when there is only one 
student in the list with row > 5?
It still sets them all to zero if I change the test to ">200" when there are 
no student.rows > 200.
But if I change the test to "<1" then nothing gets set to zero.


Jim


class student:
     def __init__ (self, name, row, column):
             self.name = name
             self.row = row
             self.column = column



for student in student_seats:
        print student.name, "row = ", student.row, "column = ", 
student.column
                if student.row > 5:
                        student.row = 0
         print student.name, "row = ", student.row, "column = ", 
student.column



More information about the Tutor mailing list