Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 List copy() Method

Python3 List copy() Method

Python3 Lists The Python3 list


Description

The copy() function copies a list, similar to a[:]。

Syntax

copy() method syntax:


list.copy()

Parameters

Return Value

Returns the new copied list.

Example

The following example shows how to use the copy() function:

Example

#!/usr/bin/python3

list1

=

[

'Google'

,

'Runoob'

,

'Taobao'

,

'Baidu'

]

list2

=

list1.

copy

(

)

print

(

"list2: "

,

list2

)

The output of the above example is:


list2 列表:  ['Google', 'Runoob', 'Taobao', 'Baidu']

Python3 Lists The Python3 list