Course Name: Python for Trading: Basic, Section No: 2, Unit No: 6, Unit type: Notebook
a = 123
b = a
id (a) 8790790947472
id (b) 8790790947472
Question : if b = a, it means b is storing a string "a". So, how can the id of a and id of b be the same as shown in the notebook ?
Hi Rushikesh,
b = a means b is storing the variable a.
b = "a" or b = 'a' means it is storing the string "a" in the variable b.
Since in the first case the variable is being referenced, it points to the same object id.
Hope this helps!