Can someone explain this behavior? When I run the code, it prints 10, then 20. Why is list_of_classes being changed even though I only changed the value of bob? Shouldn't I have to update the list with the new values?
class wooo():
def __init__(self,x,y,name):
self.x=x
self.y=y
self.name=name
bob=wooo(10,10,"bob")
joe=wooo(10,10,"joe")
list_of_classes=[bob,joe]
print(list_of_classes[0].x)
bob.x=20
print(list_of_classes[0].x)
Actual Output
10
20
Expected Output
10
10