I am relatively new to Python and love it. If I have a problem, usually I manage to find my own solutions, or relative topics that can help me understand where I messed up. But this one I can't seem to wrap my head around it.
So the issue I'm facing right now is that I give a class1.list to another class2.function, where I do some stuff there with that list. My issue is that my class1.list changes in that function and I don't understand why:
class ClassA():
def function_a(self, test):
test[0][0] = '?'
test[0][1] = '?'
return test
class ClassB():
class_b_list = [[1,2],[3,4]]
def function_b(self,value):
value[1][0] = 350
value[1][1] = 250
return value
my_class_a = ClassA()
my_class_b = ClassB()
print(my_class_b.class_b_list)
my_class_a.function_a(my_class_b.class_b_list)
my_class_b.function_b(my_class_b.class_b_list)
print(my_class_b.class_b_list)
So my first print will give me the actual value of the list: [[1,2][3,4]]
But after I give it as an attribute, my list changes to: [['?','?'][350,250]]
What am I missing? I don't want my_class_b.class_b_list to change.