Jul-19-2020, 03:51 PM
I’m reading a tutorial on mutability of lists. The gist of it is that when one list is set to be equal to another, they point to the same part of the computer’s memory, hence modifying one would also modify the other. This would not happen with integer-valued variables, as belows. Why is it so? When I type “cheese += 1”, what happens with respect to the reference stored in the variable, and the computer’s memory?
spam = 42 cheese = spam cheese += 1 cheese 43 spam 42