Python Tutoring Online
 Home

Python List copy() Method: Syntax and Examples

The Python list copy() method is used to create a new copy of an existing Python list. The copied list contains the same elements as the original list, but it is a separate list object.

The copy() method is useful when you want to modify one list without changing the original list. This is especially important when working with datasets, algorithms, loops, functions, and programs where the original data needs to be preserved.

A common beginner mistake is to use the assignment operator = when they actually need to copy a list. Assignment does not create a new list. Instead, both variables refer to the same list object. Using copy() creates a separate list.

In this tutorial, you will learn how to use the Python list.copy() method, understand its syntax and return value, copy lists safely, compare copy() with assignment and slicing, and understand the difference between shallow copy and deep copy.

Need Help Learning Python?

Understanding how Python lists are copied is an important part of learning Python programming and working with data structures.

If you are learning Python and need help understanding lists, data structures, functions, loops, assignments, or programming projects, one-to-one Python tutoring can help you learn with practical examples.

Get Python Tutoring Help

What Does copy() Do in Python?

The copy() method creates a shallow copy of a Python list. The new list contains the same elements as the original list, but the two lists are separate list objects.

For example:

numbers = [10, 20, 30]

new_numbers = numbers.copy()

After this operation, both lists contain the same values:

numbers
[10, 20, 30]

new_numbers
[10, 20, 30]

However, they are separate list objects. Adding or removing an element from one list does not change the other list when the list contains ordinary immutable elements such as integers or strings.

Python List copy() Syntax

list.copy()

The copy() method does not require any arguments.

  • list – The list that you want to copy.
  • Parameters: None
  • Return value: A new shallow copy of the list.
  • Original list: The original list remains unchanged.

Example 1: Copy a Python List Using copy()

The following example creates a copy of a list using the copy() method.

Python
numbers = [10, 20, 30]

new_list = numbers.copy()

print(new_list)

Output

[10, 20, 30]

The new list contains the same elements as the original list.

Example 2: Modify the Copied List

One of the main reasons to use copy() is to create a list that can be modified independently of the original list.

Python
numbers = [1, 2, 3]

copy_numbers = numbers.copy()

copy_numbers.append(4)

print("Original:", numbers)
print("Copy:", copy_numbers)

Output


Original: [1, 2, 3]
Copy: [1, 2, 3, 4]

The original list remains unchanged because copy_numbers is a separate list object.

Example 3: Change an Element in the Copied List

You can also change an element in the copied list without changing the corresponding element in the original list.

Python
numbers = [10, 20, 30]

copy_numbers = numbers.copy()

copy_numbers[0] = 100

print("Original:", numbers)
print("Copy:", copy_numbers)

Output


Original: [10, 20, 30]
Copy: [100, 20, 30]

The assignment to copy_numbers[0] affects only the copied list.

Example 4: Copy a List of Strings

The copy() method works with lists containing strings as well.

Python
fruits = ["apple", "banana", "cherry"]

new_fruits = fruits.copy()

print(new_fruits)

Output

['apple', 'banana', 'cherry']

The new list contains the same string elements as the original list.

Example 5: Copy a List Created Dynamically

You can copy a list after creating it dynamically during program execution.

Python
numbers = []

for i in range(5):
    numbers.append(i)

copy_numbers = numbers.copy()

print(copy_numbers)

Output

[0, 1, 2, 3, 4]

The copy() method works the same way regardless of whether the list was created directly or built during program execution.

Example 6: Check Whether Two Lists Are the Same Object

The is operator can be used to check whether two variables refer to the same object.

Python
numbers = [1, 2, 3]

copy_numbers = numbers.copy()

print(numbers is copy_numbers)
print(numbers == copy_numbers)

Output


False
True

The first result is False because the two variables refer to different list objects.

The second result is True because the lists contain the same values.

copy() vs Assignment in Python

One of the most important concepts to understand is the difference between copying a list and assigning a list to another variable.

Consider:

numbers = [1, 2, 3]

copy_numbers = numbers

This does not create a copy. Both variables refer to the same list object.

Example: Assignment Does Not Copy a List

Python
numbers = [1, 2, 3]

copy_numbers = numbers

copy_numbers.append(4)

print("Original:", numbers)
print("Other:", copy_numbers)

Output


Original: [1, 2, 3, 4]
Other: [1, 2, 3, 4]

Changing copy_numbers also changes numbers because both variables refer to the same list.

copy() vs Assignment: Important Difference

Operation New List Object? Original Affected by List Changes?
copy_numbers = numbers No Yes
copy_numbers = numbers.copy() Yes No

This distinction is particularly important when working with lists inside functions or when creating backup versions of data.

Why Use copy() Instead of Assignment?

Use copy() when you need two independent list objects that initially contain the same elements.

For example, suppose a program has a list of scores:

scores = [75, 82, 91, 68]

If you want to experiment with the data while preserving the original scores, create a copy:

new_scores = scores.copy()

You can then modify new_scores without changing scores.

Other Ways to Copy a Python List

The copy() method is not the only way to create a shallow copy of a Python list. Python provides several alternatives.

Method 1: Using copy()

copy_list = numbers.copy()

This is an explicit and readable way to copy a list.

Method 2: Using List Slicing

Python
numbers = [10, 20, 30]

copy_list = numbers[:]

print(copy_list)

Output

[10, 20, 30]

The expression numbers[:] creates a shallow copy of the list.

Method 3: Using the list() Constructor

Python
numbers = [1, 2, 3]

copy_list = list(numbers)

print(copy_list)

Output

[1, 2, 3]

The list() constructor can create a new list containing the elements of the original list.

copy() vs List Slicing vs list()

Method Creates New List? Type of Copy
numbers.copy() Yes Shallow copy
numbers[:] Yes Shallow copy
list(numbers) Yes Shallow copy
copy_numbers = numbers No Reference assignment

What Is a Shallow Copy?

The Python copy() method creates a shallow copy. This means that the outer list is copied, but objects contained inside the list are not recursively copied.

This distinction becomes important when a list contains mutable objects, such as other lists.

Shallow Copy Example with Nested Lists

Consider a list containing two inner lists:

Python
data = [[1, 2], [3, 4]]

copy_data = data.copy()

copy_data[0][0] = 99

print(data)
print(copy_data)

Output


[[99, 2], [3, 4]]
[[99, 2], [3, 4]]

At first this may seem surprising. We copied the outer list, so why did changing the copied list also affect the original?

The reason is that copy() creates a shallow copy. The outer list is new, but the inner lists are still shared between the two lists.

How Shallow Copy Works

Suppose you have:

data = [[1, 2], [3, 4]]

When you create:

copy_data = data.copy()

Python creates a new outer list, but the inner list objects are still referenced by both lists.

Conceptually:

data       →  [ inner_list_1, inner_list_2 ]

copy_data  →  [ inner_list_1, inner_list_2 ]

The outer lists are different, but the nested objects are shared.

Shallow Copy vs Deep Copy

A shallow copy copies the outer list but does not recursively copy nested objects.

A deep copy recursively copies the objects contained inside the list as well.

Feature Shallow Copy Deep Copy
Outer list copied? Yes Yes
Nested mutable objects copied? No Yes
Nested lists shared? Yes No
Python list copy()? Yes No

How to Create a Deep Copy of a List

When a list contains nested mutable objects and you need a completely independent copy, Python's copy module provides deepcopy().

Python
import copy

data = [[1, 2], [3, 4]]

copy_data = copy.deepcopy(data)

copy_data[0][0] = 99

print(data)
print(copy_data)

Output


[[1, 2], [3, 4]]
[[99, 2], [3, 4]]

In this example, changing the nested list inside copy_data does not change the nested list inside data.

When Should You Use copy()?

The copy() method is useful when you need an independent version of a list containing values that do not require recursive copying.

Common uses include:

Copying Lists Before Sorting

The copy() method is especially useful when you want to sort a list while preserving the original order.

Python
numbers = [30, 10, 40, 20]

sorted_numbers = numbers.copy()

sorted_numbers.sort()

print("Original:", numbers)
print("Sorted:", sorted_numbers)

Output


Original: [30, 10, 40, 20]
Sorted: [10, 20, 30, 40]

The original list remains in its original order because sort() was applied to the copied list.

Copying a List Before Reversing It

You can also use copy() when you want to reverse a list while preserving its original order.

Python
numbers = [1, 2, 3, 4]

reversed_numbers = numbers.copy()

reversed_numbers.reverse()

print("Original:", numbers)
print("Reversed:", reversed_numbers)

Output


Original: [1, 2, 3, 4]
Reversed: [4, 3, 2, 1]

Copying a List Before Removing Elements

A copy can also be useful when you need to remove elements from one version of a list while preserving the original.

Python
numbers = [10, 20, 30, 40]

new_numbers = numbers.copy()

new_numbers.remove(20)

print("Original:", numbers)
print("Modified copy:", new_numbers)

Output


Original: [10, 20, 30, 40]
Modified copy: [10, 30, 40]

Copying Lists in Functions

Understanding list copying is also important when working with functions. Python lists are mutable objects, so modifying a list inside a function can affect the original list.

Creating a copy allows a function to work with an independent list when that is the desired behavior.

Python
def add_number(numbers):
    new_numbers = numbers.copy()
    new_numbers.append(100)
    return new_numbers

numbers = [1, 2, 3]

result = add_number(numbers)

print("Original:", numbers)
print("Result:", result)

Output


Original: [1, 2, 3]
Result: [1, 2, 3, 100]

Here, the function creates a copy before adding the new value, so the original list remains unchanged.

copy() and Mutable Lists

The need for copy() is closely related to the fact that Python lists are mutable. A mutable object can be changed after it has been created.

For example:

numbers = [1, 2, 3]

numbers.append(4)

The existing list has been modified rather than a new list being created. When multiple variables refer to the same list, this can sometimes produce unexpected results.

Using copy() gives you a separate outer list that can be modified independently.

What Happens When You Copy an Empty List?

The copy() method can also be used with an empty list.

Python
numbers = []

new_numbers = numbers.copy()

print(new_numbers)

Output

[]

The result is another empty list object.

Copying a List with Duplicate Values

Duplicate elements are copied normally.

Python
numbers = [1, 2, 2, 3, 2]

new_numbers = numbers.copy()

print(new_numbers)

Output

[1, 2, 2, 3, 2]

The copy() method does not remove duplicates or change the values of the original list.

Does copy() Copy the Elements?

For a shallow copy, the new outer list contains references to the same objects contained in the original list.

For simple immutable values such as integers and strings, this usually behaves exactly as beginners expect because those values cannot be changed in place.

For mutable objects such as nested lists, dictionaries, or other mutable objects, the distinction becomes important because the objects may still be shared.

Common Beginner Mistakes with copy()

Mistake 1: Using Assignment Instead of copy()

This:

new_list = original_list

does not create a copy. Both variables refer to the same list.

Use:

new_list = original_list.copy()

when you need a separate list object.

Mistake 2: Assuming copy() Creates a Deep Copy

The copy() method creates a shallow copy. Nested mutable objects are not recursively copied.

For a completely independent nested structure, consider copy.deepcopy().

Mistake 3: Confusing == with is

The == operator checks whether two lists contain equal values, while is checks whether they are the same object.

Python
numbers = [1, 2, 3]

new_numbers = numbers.copy()

print(numbers == new_numbers)
print(numbers is new_numbers)

Output


True
False

Mistake 4: Expecting Changes to a Copy to Affect the Original

For a normal list containing immutable values, modifying the copied list does not modify the original list.

However, with nested mutable objects, a shallow copy can still share those nested objects.

Python List copy() vs deepcopy()

Feature copy() deepcopy()
Creates new outer list? Yes Yes
Copies nested mutable objects? No Yes
Type Shallow copy Deep copy
Module required? No copy module

Python List copy() vs Assignment

Code New List? Lists Independent?
b = a No No
b = a.copy() Yes Yes*

*The copied outer list is independent, but nested mutable objects may still be shared because copy() creates a shallow copy.

Python List copy() Time Complexity

Creating a shallow copy of a list requires Python to process the elements of the list, so the time complexity of list.copy() is O(n), where n is the number of elements in the list.

The amount of memory required for the new outer list is also proportional to the number of elements.

Python List copy() Method: Key Points

Frequently Asked Questions About Python List copy()

What is copy() in Python?

The copy() method creates a shallow copy of a Python list. The new list contains the same elements as the original list but is a separate list object.

How do I copy a list in Python?

Use the copy() method:

numbers = [1, 2, 3]

new_numbers = numbers.copy()

Does Python list copy() create a new list?

Yes. The copy() method creates a new outer list containing the elements of the original list.

Does copy() modify the original list?

No. Calling copy() does not modify the original list.

What is the difference between copy() and = in Python?

Assignment using = makes another variable refer to the same list. The copy() method creates a separate list object.

Is Python list copy() a shallow copy?

Yes. list.copy() creates a shallow copy. The outer list is copied, but nested mutable objects are not recursively copied.

How do I copy a nested list in Python?

If you only need a shallow copy, you can use:

new_list = original_list.copy()

If you need to recursively copy nested objects, use copy.deepcopy().

What is the difference between copy() and deepcopy()?

copy() creates a shallow copy, while deepcopy() recursively copies nested objects as well.

What is the difference between copy() and slicing?

Both list.copy() and list[:] create shallow copies of a list. The copy() method is often more explicit and easier to understand when the intention is to copy the list.

What is the difference between copy() and list()?

For a list, both original.copy() and list(original) create a new shallow list containing the same elements.

What happens if I change the copied list?

When the list contains ordinary immutable values, changing the copied list does not change the original list because the outer lists are separate objects.

Can copy() copy a list containing another list?

Yes. However, copy() creates a shallow copy, so the nested list itself is still shared between the original and copied outer lists.

Why does changing a nested list affect the original after copy()?

Because copy() creates a shallow copy. The outer list is new, but the nested mutable list is still referenced by both lists.

What is the time complexity of list.copy()?

The time complexity of copying a list is O(n), where n is the number of elements in the list.

Related Python List Tutorials

Learn More Python List Methods

The copy() method is one of many built-in Python list methods used to work with and manipulate list data.

Continue learning Python lists to understand how to add, remove, search, sort, reverse, copy, and process elements using practical Python examples.

Learn Python Lists




Stuck Learning Python?

Struggling with Python syntax, assignments or debugging errors? Learning alone can be frustrating.

Get 1-on-1 Python tutoring and learn faster with clear explanations, real examples and live help.

    Get Python Tutoring

PythonTutor.net

Home    Tutorial     Online Live Trainings    Contact Us           © 2026 All rights reserved by www.PythonTutor.net