How to Copy a List in Python
If you want to copy a list in Python, the safest beginner-friendly choice is usually list.copy().
This page shows you:
- how to copy a list without changing the original list object
- which copy method to use for common cases
- why some copied lists still affect each other
- when you need a deep copy instead of a normal copy
Quick answer
numbers = [1, 2, 3]
copy_numbers = numbers.copy()
print(numbers)
print(copy_numbers)
print(numbers is copy_numbers)
Output:
[1, 2, 3]
[1, 2, 3]
False
Use list.copy() for a simple shallow copy of a list. This creates a new list object, but nested items are still shared.
What this page helps you do
After reading this page, you should be able to:
- copy a list without changing the original list object
- choose the simplest copy method for beginner use cases
- understand why some copied lists still affect each other
- avoid accidental shared data with nested lists
If you are new to lists in general, see Python lists explained for beginners.
Use list.copy() for a simple copy
For most beginners, list.copy() is the best way to copy a list.
It:
- creates a new list object
- keeps the same items
- works well for simple lists of numbers or strings
- makes a shallow copy
Example:
fruits = ["apple", "banana", "orange"]
copied_fruits = fruits.copy()
copied_fruits.append("grape")
print("Original:", fruits)
print("Copy:", copied_fruits)
Output:
Original: ['apple', 'banana', 'orange']
Copy: ['apple', 'banana', 'orange', 'grape']
Why this works
fruits.copy() makes a new outer list.
That means adding or removing items from copied_fruits does not change fruits.
If you want more detail on this method, see the Python list copy() method reference.
Other common ways to copy a list
There are a few other common ways to copy a list.
1. Use slicing
numbers = [10, 20, 30]
copied_numbers = numbers[:]
print(copied_numbers)
print(numbers is copied_numbers)
Output:
[10, 20, 30]
False
numbers[:] creates a shallow copy of the list.
2. Use list()
letters = ["a", "b", "c"]
copied_letters = list(letters)
print(copied_letters)
print(letters is copied_letters)
Output:
['a', 'b', 'c']
False
list(letters) builds a new list from the old one.
3. Do not use =
This is a very common beginner mistake:
original = [1, 2, 3]
copied = original
copied.append(4)
print("Original:", original)
print("Copied:", copied)
Output:
Original: [1, 2, 3, 4]
Copied: [1, 2, 3, 4]
This is not a real copy.
All of these common methods make shallow copies:
my_list.copy()my_list[:]list(my_list)
Why = does not copy a list
When you write this:
old_list = [1, 2, 3]
new_list = old_list
Python does not make a new list.
Instead, both variables point to the same list in memory.
You can check that with is:
old_list = [1, 2, 3]
new_list = old_list
print(old_list is new_list)
Output:
True
Now if you change one variable, the other appears to change too:
old_list = [1, 2, 3]
new_list = old_list
new_list.append(4)
print(old_list)
print(new_list)
Output:
[1, 2, 3, 4]
[1, 2, 3, 4]
This is called assignment, not copying.
Shallow copy vs nested lists
A shallow copy copies only the outer list.
If your list contains inner lists or other mutable objects, those nested items are still shared.
Example:
original = [[1, 2], [3, 4]]
copied = original.copy()
copied[0].append(99)
print("Original:", original)
print("Copied:", copied)
print(original is copied)
print(original[0] is copied[0])
Output:
Original: [[1, 2, 99], [3, 4]]
Copied: [[1, 2, 99], [3, 4]]
False
True
What happened here?
original is copiedisFalse, so the outer lists are differentoriginal[0] is copied[0]isTrue, so the first inner list is shared- changing the inner list affects both variables
This is the main reason copied lists sometimes behave in surprising ways.
If you want a fuller explanation, see shallow copy vs deep copy explained.
When to use deepcopy
Use copy.deepcopy() when your list contains nested mutable data, such as:
- lists inside lists
- dictionaries inside lists
- sets inside lists
A deep copy creates independent copies of nested mutable items.
Example:
import copy
original = [[1, 2], [3, 4]]
copied = copy.deepcopy(original)
copied[0].append(99)
print("Original:", original)
print("Copied:", copied)
print(original[0] is copied[0])
Output:
Original: [[1, 2], [3, 4]]
Copied: [[1, 2, 99], [3, 4]]
False
Now the inner lists are separate too.
Use deepcopy() only when you really need full separation. For simple one-dimensional lists, .copy() is usually enough.
Which method should beginners use
A good rule is:
- use
.copy()for most simple list-copy tasks - use
deepcopy()only for nested mutable data - use
=only when you want both variables to refer to the same list - choose the clearest method, not the cleverest one
In most beginner code:
numbers.copy()is the easiest to readnumbers[:]is fine, but less obvious to some beginnerslist(numbers)also works, but.copy()is usually clearer for lists
Common mistakes
These are the most common reasons list copying goes wrong:
- using
=and expecting a new list - copying a nested list with
.copy()and expecting a deep copy - changing inner lists after making only a shallow copy
- not knowing the difference between assignment and copying
If your code behaves unexpectedly, print a few values to check what is shared.
Useful debugging lines:
print(original)
print(copied)
print(original is copied)
print(id(original))
print(id(copied))
print(original[0] is copied[0])
What these checks tell you
original is copiedchecks whether both variables point to the same objectid(original)andid(copied)show the memory identity of each objectoriginal[0] is copied[0]helps you detect shared nested items
FAQ
What is the easiest way to copy a list in Python?
Use my_list.copy() for a simple shallow copy.
Does new_list = old_list copy the list?
No. It creates another reference to the same list.
What is a shallow copy?
It copies the outer list, but nested mutable items are still shared.
How do I copy a nested list without linking inner items?
Use copy.deepcopy() from the copy module.
Is slicing a good way to copy a list?
Yes. my_list[:] creates a shallow copy and is commonly used.