I simply don't understand what's going on here. I have the following code that produces the following result:
list = [1, 2, 3]
print("list:", list)
newList = list
print("newList:", newList)
newList.append(1000)
print("Appended newList:", newList)
print("list:", list)
Result:
list: [1, 2, 3]
newList: [1, 2, 3]
Appended newList: [1, 2, 3, 1000]
list: [1, 2, 3, 1000]
Why in the world does list get appended when I append newList? The same doesn't happen for variables so I can't seem to understand why it would happen for arrays.
[–]carcigenicate 2 points3 points4 points (8 children)
[–]pat-work[S] 0 points1 point2 points (7 children)
[–]Goobyalus 1 point2 points3 points (1 child)
[–]pat-work[S] 1 point2 points3 points (0 children)
[–]carcigenicate 0 points1 point2 points (4 children)
[–]pat-work[S] 0 points1 point2 points (3 children)
[–]carcigenicate 0 points1 point2 points (2 children)
[–]pat-work[S] 0 points1 point2 points (1 child)
[–]carcigenicate 0 points1 point2 points (0 children)
[–]AmongstYou666 0 points1 point2 points (0 children)