list.copy() Shallow copy
Last updated: 2026-09-22
list.copy() Shallow copy
list.copy() returns a shallow copy; equivalent to lst[:].
| Category | List Methods |
|---|---|
| Kind | Built-in Type Method |
| Python Version | all |
📝 Syntax
list.copy()
Returns:A new list that is a shallow copy (same as lst[:]).
Mutates the original:No (returns a new object)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
[1, [2, 3, 4]]
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QIs copy() a deep copy?
ANo, it is a shallow copy. The outer layer is a new list, but the mutable elements inside are still shared: after b = a.copy(), modifying b[0][0] will affect a (if a[0] is a list).
QHow do I get a fully independent copy?
AUse copy.deepcopy(lst) (you need to import copy).
QWhat equivalent forms exist?
Alst[:] and list(lst) are also shallow copies with the same effect as copy().