Performing a shallow copy of a list

suggest change

You can create shallow copies of lists using slices.

>>> l1 = [1,2,3]
>>> l2 = l1[:]     # Perform the shallow copy.
>>> l2
[1,2,3]
>>> l1 is l2
False

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents