The list is a container data type that represents an ordered collection of elements.

The copy() method in lists is  used to get a shallow copy of the target list. A copy operation occurs when we create a new list using the elements of an existing list. In shallow copy, it is the references to the elements of the original list that are added to the new list. This means that if the elements of the copied list are mutable, any modification in either the copied list or the original list will be reflected in the other list.

mylist = ['a', 'b', 'c']

mylist_copy = mylist.copy()


In the above example, we created a list of strings then created a copy of the list using the copy() method.

The syntax of the copy() method is as shown below:


The function takes no argument, when called, it returns a new list which is a shallow copy of the current list.

lst = [0, 1, 2, 3, 4]

lst_copy = lst.copy()


with a list of mutable elements

When the list contains mutable elements, the copied list contains the references to the actual elements rather than their copy. This means that an operation done on an element that is mutable in either the original or the copy lists will be reflected on the other list.

#a list of lists
mylist = [ [1, 2], [10, 20], [100, 200]]

mylist_copy = mylist.copy()

#change an inner list from the original list
mylist[0][1] = 10000
#the change is reflected in the copy list

#change an inner through the copy
mylist_copy[-1][1] = 20000
#the change is reflected on the original list

In the above example, we demonstrated what we mean by shallow copies and that changing a mutable element from the original list will affect the copied list and vice verse.