I’m curious about the difference and relationship between id(L) and id(L[:]), where L is a list.
The official documentation says this about id():
CPython implementation detail: This is the address of the object in memory.
But I don’t understand why id(L) and id(L[:]) have different values.
L[:]produces a copy of the list. Its a whole new list contain the same items as L. As a result, its stored in a different place in memory and has a different id.