Python3 List copy() Method
Description
The copy() function copies a list, similar to a[:]。
Syntax
copy() method syntax:
list.copy()
Parameters
- none.
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
(
)
(
"list2: "
,
list2
)
The output of the above example is:
list2 列表: ['Google', 'Runoob', 'Taobao', 'Baidu']
The Python3 list