I finally figured out what happens to previous data when a variable changes value

I finally figured out what happens to previous data when a variable changes value

whenever you reassign a variable, the old value doesn't get erased by the new one; the variable simply switches to refer to the new value. The effect is like moving a sticky note from one object to another.
a = 10 a = 12
when you do something like this, 10 is not deleted or removed, it will still be there somewhere in your computer memory, another memory is been created for 12 and a is now made to point to this new value(yea python relates with c)

By the way, even though the assignment statement doesn't directly cause the old value of a variable to be erased and overwritten, you don't have to worry about computer memory getting filled up with the "discarded" values.

When a value is no longer referred to by any variable, it is no longer useful. Python will automatically clear these values out of memory so that the space can be used for new values.

In fact, this process of automatic memory management is actually called garbage collection.