So I have the following code:
class Table:
children = [False, False]
def __repr__(self):
return str(self.children)
classroom = [Table(), Table(), Table(), Table()]
def update():
classroom[1].children[0] = True
print(classroom)
update()
Which is supposed to edit the second element within the list "classroom" and print out:
[[False, False], [True, False], [False, False], [False, False]]
But somehow updating the list on line 12 updates every instance of the class, giving me this:
[[True, False], [True, False], [True, False], [True, False]]
I've tried using the global keyword within the function but it seems to have no affect, am I missing something?