When I build a list in a class, the objects build from that class share the same list. I mean, changes in the list of obj1 will happen in obj2's list.
That doesn't happen with other data types like strings.
Why that happens?
And how can I avoid that?
There goes an example:
class Class:
list = list()
def list_appender(self,arg):
self.list.append(arg)
obj1 = Class()
obj2 = Class()
obj1.list_appender(4)
obj1.list_appender(5)
obj1.list_appender(6)
print(obj2.list)
Answer = [4, 5, 6]