The following code creates a list, assigns a slice of the list to a new variable, and then modifies this slice using the new variable B. The memory addresses of the elements of A and B are the same, but modifying B does not affect A. What am I missing here?
def printAddresses(A):
    for i in range(len(A)):
        print(f"memory address of list element {i}: {hex(id(A[i]))}")
    print("\n\n\n")
A = list(range(5))
B = A[:]
print("addresses of elements of A")
printAddresses(A)
print("addresses of elements of B")
printAddresses(B)
for i in range(len(B)):
    B[i]=12345
print("A: ", A)
print("B: ", B)
Output:
addresses of elements of A
memory address of list element 0: 0x10821e470
memory address of list element 1: 0x10821e490
memory address of list element 2: 0x10821e4b0
memory address of list element 3: 0x10821e4d0
memory address of list element 4: 0x10821e4f0
addresses of elements of B
memory address of list element 0: 0x10821e470
memory address of list element 1: 0x10821e490
memory address of list element 2: 0x10821e4b0
memory address of list element 3: 0x10821e4d0
memory address of list element 4: 0x10821e4f0
A:  [0, 1, 2, 3, 4]
B:  [12345, 12345, 12345, 12345, 12345]
 
    