Python Tutorials · Python Lists

Copy Lists

Learn all about Copy Lists in this comprehensive tutorial.

5 min read beginner
  • You cannot copy a list simply by typing list2 = list1, because: list2 will only be a reference to list1, and changes made in list1 will automatically also be made in list2.
  • You can use the built-in List method copy() to copy a list.
  • Another way to make a copy is to use the built-in method list().
  • You can also make a copy of a list by using the : (slice) operator.

Copy a List

You cannot copy a list simply by typing list2 = list1, because: list2 will only be a reference to list1, and changes made in list1 will automatically also be made in list2.

Use the copy() method

You can use the built-in List method copy() to copy a list.

python

Use the list() method

Another way to make a copy is to use the built-in method list().

python

Use the slice Operator

You can also make a copy of a list by using the : (slice) operator.

python

Module quiz

2 questions
1

Which of the following is true about Copy Lists?

2

What is the most common pitfall when working with Copy Lists?

Answer all questions to submit.