Python List copy() Method
list.copy() creates a new list with the same items as an existing list.
This method is useful when you want to work with a list without changing the original one. It is especially important for beginners because using = does not make a real copy.
Quick example
numbers = [1, 2, 3]
new_numbers = numbers.copy()
new_numbers.append(4)
print(numbers) # [1, 2, 3]
print(new_numbers) # [1, 2, 3, 4]
Use list.copy() when you want a new list object with the same items. This is a shallow copy.
What list.copy() does
list.copy():
- Creates a new list with the same items as the original list
- Returns that new list
- Makes the original list and copied list different objects
- Lets you change the new list without affecting the original list when the list contains simple values like numbers or strings
Example:
fruits = ["apple", "banana", "orange"]
copied_fruits = fruits.copy()
print(fruits)
print(copied_fruits)
Output:
['apple', 'banana', 'orange']
['apple', 'banana', 'orange']
Even though the contents are the same, these are two different lists.
Basic syntax
The syntax is:
new_list = old_list.copy()
How it works:
- Call
copy()on an existing list - Save the returned value in a new variable
- Use the new variable as your copied list
Example with an empty list:
empty_list = []
new_empty_list = empty_list.copy()
print(new_empty_list)
Output:
[]
This works for both empty and non-empty lists.
Why not use =
Using = does not create a new list.
It only creates a new variable that points to the same list in memory.
numbers = [1, 2, 3]
same_list = numbers
same_list.append(4)
print(numbers)
print(same_list)
Output:
[1, 2, 3, 4]
[1, 2, 3, 4]
Both variables refer to the same list, so changing one also changes the other.
Now compare that with copy():
numbers = [1, 2, 3]
copied_numbers = numbers.copy()
copied_numbers.append(4)
print(numbers)
print(copied_numbers)
Output:
[1, 2, 3]
[1, 2, 3, 4]
If you want to learn more about creating and working with lists, see Python lists explained for beginners.
Shallow copy meaning
list.copy() makes a shallow copy.
That means:
- The outer list is new
- But nested mutable items inside it can still be shared
This matters when your list contains other lists.
original = [[1, 2], [3, 4]]
copied = original.copy()
copied[0].append(99)
print(original)
print(copied)
Output:
[[1, 2, 99], [3, 4]]
[[1, 2, 99], [3, 4]]
Why did both change?
originalandcopiedare different outer lists- But the inner list
original[0]is the same object in both lists
So copy() is usually safe for simple lists like:
- Numbers
- Strings
- Booleans
If you need to understand this better, read Python shallow copy vs deep copy explained.
Return value
list.copy() returns a new list.
It does not change the original list by itself.
You must save the result if you want to use the copied list.
Correct:
colors = ["red", "blue"]
new_colors = colors.copy()
print(new_colors)
Incorrect if you expected a saved copy:
colors = ["red", "blue"]
colors.copy()
print(colors)
In the second example, copy() runs, but the returned list is not stored anywhere.
When to use list.copy()
Use list.copy() when:
- You want to edit a list without changing the original
- You want to pass a list to code that may modify it
- You want a simple backup before making changes
- You want a clear alternative to slicing with
[:]
Example:
scores = [10, 20, 30]
backup_scores = scores.copy()
scores.append(40)
print(scores)
print(backup_scores)
Output:
[10, 20, 30, 40]
[10, 20, 30]
If you want to add items after copying, see Python list append() method.
Common beginner mistakes
Here are the most common problems with list.copy().
Using = and expecting a real copy
This is the most common mistake.
a = [1, 2, 3]
b = a
b.append(4)
print(a) # [1, 2, 3, 4]
Fix: use copy() instead.
a = [1, 2, 3]
b = a.copy()
b.append(4)
print(a) # [1, 2, 3]
Forgetting to save the returned list
numbers = [1, 2, 3]
numbers.copy()
This creates a copy, but you do not keep it.
Fix:
numbers = [1, 2, 3]
copied_numbers = numbers.copy()
Assuming nested lists are fully copied
a = [[1], [2]]
b = a.copy()
b[0].append(99)
print(a) # [[1, 99], [2]]
Fix: remember that list.copy() is shallow.
Trying to use copy() on the wrong data type
copy() here is a list method, so the value must be a list.
name = "Alice"
# name.copy() # This would raise an error
If you are not sure what the variable contains, check its type:
print(type(name))
You can also review creating a list in Python if you need a quick refresher.
FAQ
Does list.copy() change the original list?
No. It returns a new list. The original list stays the same unless you change it separately.
What is the difference between list.copy() and =?
copy() creates a new list. = creates another reference to the same list.
Is list.copy() a deep copy?
No. It is a shallow copy. Nested mutable items are still shared.
Can I copy an empty list?
Yes. empty_list.copy() returns another empty list.
Is list.copy() the same as [:]?
For basic list copying, yes. Both create a shallow copy of the list.