Hello everyone,
I struggle with a python code. I found the problem and reproduced the condition of its occurence in the following lines:
Yet I get
Why does the code modify the A list?
And how can I stop it from doing so?
I'm really thankful for any help, I've been stuck for a while on that :D
I struggle with a python code. I found the problem and reproduced the condition of its occurence in the following lines:
def PLS(A): B = A B[0] = B[2] return(B) A = [1,2,3] D = PLS(A) print(A)Compiling those few lines, I expect
D
to be [2,3,2]
and A
to be [1,2,3]
. Yet I get
D = A = [2,3,2]
Why does the code modify the A list?
And how can I stop it from doing so?
I'm really thankful for any help, I've been stuck for a while on that :D