Python List – copy()

Python list.copy() method makes a shallow copy of the elements in original list, and returns the copy.

Syntax

The syntax to call copy() method on a list myList is

myList.copy()

where

  • myList is a Python list
  • copy is method name
ADVERTISEMENT

Examples

Copy a List

In the following program, we initialize a list myList with some elements. We copy this list into a new list copyList, using copy() method.

main.py

#take a list
myList = ['apple', 'banana', 'cherry']
print(f'original list : {myList}')

#make a copy of the list
copyList = myList.copy()
print(f'list copy     : {copyList}')
Try Online

Output

original list : ['apple', 'banana', 'cherry']
list copy     : ['apple', 'banana', 'cherry']

Conclusion

In this Python Tutorial, we learned how to copy elements of a list into another list, using list.copy() method.