This is because when an object is assigned to a variable in Python, the variable simply points to the memory location where the object is stored. When the variable is reassigned to a different object, it simply points to a new memory location. The original object is still stored in memory and can be accessed through its original reference, if it has not been garbage collected. Therefore, any changes made to the original object will still be reflected, even if the variable that initially pointed to it has been reassigned.
Asked: 2022-04-27 11:00:00 +0000
Seen: 8 times
Last updated: Oct 06 '21