Jim Morcombe wrote: > 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: >
Try making your index variable (student) something that is not the same name as the class. > 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 > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor