Python List - Copy Method

Method Name:

copy

Method Signature:

copy()

Method Overview:

  • The copy() method returns a shallow copy of the Python list object.
  • A new list is created and the references to the elements that are present in the orginal list are copied into the new list. Note that, the elements present in the original list are not cloned. Hence, this is a shallow copy.

Parameters:

None

Return Type:

None

Example:

>>> objects=['Calculator','Integrated Chip','Logical Gate']

>>> objects_copy=objects.copy()

>>> print(objects_copy)

['Calculator', 'Integrated Chip', 'Logical Gate']


Copyright 2023 © pythontic.com