list01 = [11, 22, 33, 44, 55]
print ( " The memory address of the variable list01: " , id ( list01 ))
print ( " The memory address of the first element of list01: " , id ( list01 [ 0 ]))
list02 = list01
print(list02)
print ( " The memory address of the variable list02: " , id (list02))
print ( " The memory address of the first element of list02: " , id (list02[ 0 ]))
list03 = [11, 55]
print(list03)
print ( " The memory address of the variable list03: " , id (list03))
print ( " The memory address of the first element of list03: " , id (list03[ 0 ]))
list01.append( 66 ) #Add elements
print(list01)
print(list02)
list01[0] = 99
print(list01)
print(list02)
print(list03)
Results of the:
C: \ python \ python.exe C: /python/demo/file3.py
Memory address of list01 variable: 2440165266888
The memory address of the first element of list01 : 1642098464
[11, 22, 33, 44, 55]
Memory address of list02 variable: 2440165266888
The memory address of the first element of list02 : 1642098464
[11, 55]
Memory address of list03 variable: 2440166083464
The memory address of the first element of list03 : 1642098464
[11, 22, 33, 44, 55, 66]
[11, 22, 33, 44, 55, 66]
[99, 22, 33, 44, 55, 66]
[99, 22, 33, 44, 55, 66]
[11, 55]
Process finished with exit code 0