What happens when we assign same values in two variables, is their address remains same?

All QuestionsCategory: PythonWhat happens when we assign same values in two variables, is their address remains same?
chetan shidling asked 4 years ago

I need short information.

2 Answers
chetan shidling answered 4 years ago

Let’s see one example:

>>> a = 10
>>> b = a
>>> a

10

>>> b

10

>>> id(a)            //To get address

1864841616

>>> id(b)

1864841616
The address is same because the value of both variables are same, that’s why python is called memory efficient.

Krishan answered 4 years ago

Thank you so much