This works:
Thanks,
Bassam
A=[1] B=A.copy() print(B) print(A) print(B) B.append(2) print(B) print(A) print(B)This does not:
A=[[1]] B=A.copy() print(B) print(A) print(B) B[0].append(2) print(B) print(A) # Bad A here. print(B)A is getting modified. Any reason why?
Thanks,
Bassam
Larz60+ write Aug-19-2023, 01:06 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Tags added. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Tags added. Please use BBCode tags on future posts.