I have two lists A and B when i change A it change also at B how i prevent this?
A = [1,2,3,4,5]
B = A
A.append(6)
print(A)
print(B)
thank's for the help.
I have two lists A and B when i change A it change also at B how i prevent this?
A = [1,2,3,4,5]
B = A
A.append(6)
print(A)
print(B)
thank's for the help.
You have one list, and two variables pointing to it.
To make B
point to a copy of A
, you can use B = list(A)
.