Variable assignment - basic question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Variable assignment - basic question

A=[0,1,2] B=A A[0]=‘spam’ print(B[0]) Results in: spam How is B made a copy of A? So that B remains the original A even if there are subsequent assignments in A?

27th Aug 2019, 3:46 AM
Triq
1 Answer
0
thanks! that did as i expected. i program in matlab a lot, so the behavior was different and unexpected.
28th Aug 2019, 3:35 AM
Triq