list.copy
Create a shallow copy of the list.
Python 3.13
list.copy()Return value
A new list with the same items.
Examples
The copy changes separately from the original
Python 3.13
a = [1, 2]
b = a.copy()
b.append(3)
print(a, b)[1, 2] [1, 2, 3]
A nested list stays shared
Python 3.13
a = [[1, 2], [3]]
b = a.copy()
b[0].append(99)
print(a)[[1, 2, 99], [3]]
Details
The copy is shallow: nested lists and other mutable objects stay shared between the original and the copy. For a full copy, use copy.deepcopy.
