---
title: "copying lists"
url: https://perrotta.dev/2025/11/copying-lists/
last_updated: 2026-01-03
---


All assertions are correct:

```python
a = [1, 2, 3]

b = a
assert b is a
assert a is b # (duh!)
assert b == a

c = a[:]  # slicing
assert c is not a
assert c == a

d = a.copy()
assert d is not a
assert d == a

from copy import copy
e = copy(a)
assert e is not a
assert e == a

from copy import deepcopy
f = deepcopy(a)
assert f is not a
assert f == a
```

