Aug-29-2020, 01:37 PM
What I understand is Python uses shared reference for variables.
I verified by assigning two variables with value of 10 (int). They both had the same memory address.
Thanks.
I verified by assigning two variables with value of 10 (int). They both had the same memory address.
>>> a = 10 >>> b = 10 >>> hex(id(a)) '0x7fe4741d69c0' >>> hex(id(b)) '0x7fe4741d69c0'But when I assigned a value of 500, they have difference memory address.
>>> c = 500 >>> d = 500 >>> hex(id(c)) '0x7fe4669f6a30' >>> hex(id(d)) '0x7fe4669f6b30'How come? What changed in value 500?
Thanks.