Module (16%)
Section (29%)

When you have two variables referring to the same object, the return values of the id() function must be the same.

Run the code presented in the right pane to confirm our speculations:

a_string identity: 8466704 b_string identity: 8466704

output

In this example, we haven’t created a new list, but just created a new label that references the already created list.

This interesting behavior will be examined on the following pages.


Code

a_string = '10 days to departure'
b_string = a_string

print('a_string identity:', id(a_string))
print('b_string identity:', id(b_string))
{{ dockerServerErrorMsg }} ×
{{ errorMsg }} ×
{{ successMsg }} ×