Easy Tutorial
❮ Ref Math Degrees Python Os Access ❯

Python3 List copy() Method

Python3 List


Description

The copy() function is used to duplicate a list, similar to a[:].

Syntax

Syntax for the copy() method:

list.copy()

Parameters

Return Value

Returns a new list that is a copy.

Example

The following example demonstrates the use of the copy() function:

#!/usr/bin/python3

list1 = ['Google', 'tutorialpro', 'Taobao', 'Baidu']
list2 = list1.copy()
print("list2 list: ", list2)

The output of the above example is as follows:

list2 list:  ['Google', 'tutorialpro', 'Taobao', 'Baidu']

Python3 List

❮ Ref Math Degrees Python Os Access ❯