12
A minor headache for a beginner coder
(lemmy.dbzer0.com)
Welcome to the Python community on the programming.dev Lemmy instance!
Past
November 2023
October 2023
July 2023
August 2023
September 2023
Everything's an object. A variable is a pointer to an object. var1 is a pointer to the object 1 (which is an integer). var2 is also a pointer to the same object. If you point var1 to a different object (the integer 2), that doesn't change var2. list1 is a pointer to the list object you defined. list2 is a pointer to the same object. If you change the object, both pointers still point to it.
At least that's my understanding of the whole business. If I got anything wrong, in sure somebody will point it out.