{"id":24702,"date":"2021-10-25T09:11:43","date_gmt":"2021-10-25T03:41:43","guid":{"rendered":"https:\/\/python-programs.com\/?p=24702"},"modified":"2021-11-05T17:20:41","modified_gmt":"2021-11-05T11:50:41","slug":"python-list-copy-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-list-copy-method-with-examples\/","title":{"rendered":"Python List copy() Method with Examples"},"content":{"rendered":"

In the previous article, we have discussed Python List clear() Method with Examples<\/a>
\nList in Python:<\/strong><\/p>\n

Lists in Python are mutable sequences. They are extremely similar to tuples, except they do not have immutability constraints. Lists are often used to store collections of homogeneous things, but there is nothing stopping you from storing collections of heterogeneous items as well.<\/p>\n

List copy() Method in Python:<\/strong><\/p>\n

The copy() method returns a duplicate (copy) of the specified list.<\/p>\n

Syntax:<\/strong><\/p>\n

list.copy()<\/pre>\n

Parameter Values: <\/strong>This method has no parameters.<\/p>\n

Return Value:<\/strong><\/p>\n

A new list is returned by the copy() function. It makes no changes to the original list.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given List = ['hello', 'this', 'is', 'btechgeeks']<\/pre>\n

Output:<\/strong><\/p>\n

The given list is :  ['hello', 'this', 'is', 'btechgeeks']\r\nThe new list after applying copy() function is :\r\n['hello', 'this', 'is', 'btechgeeks']<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given List = [20, 40, 60, 80, 100]<\/pre>\n

Output:<\/strong><\/p>\n

The given list is :  [20, 40, 60, 80, 100]\r\nThe new list after applying copy() function is :\r\n[20, 40, 60, 80, 100]<\/pre>\n

List copy() Method with Examples in Python<\/h2>\n