Answer the question
In order to leave comments, you need to log in
How are matrices assigned?
An A-matrix in python, an empty
B-matrix in python, with data I
assign A=B,
I start changing the data in A and the data in B changes, what should I do to prevent this from happening and why does this happen?
Answer the question
In order to leave comments, you need to log in
Why is this happening?
a = [1,2,3,5,6]
b = a
print(id(a))
print(id(b))
# 1552394418184
# 1552394418184
what to do to prevent this from happening
b = a.copy()
print(id(a))
print(id(b))
# 1552394980744
# 1552395031496
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question