Python3 List copy() Method
Description
The copy() function is used to copy a list, similar toa[:]。
Syntax
Syntax of the copy() method:
list.copy()
Parameters
- None.
Return Value
Returns a new list after copying.
Example
The following example demonstrates how to use the copy() function:
Example
#!/usr/bin/python3
list1 = ['Google', 'Example', 'Taobao', 'Baidu']
list2 = list1.copy()
print ("list2 list: ", list2)
list1 = ['Google', 'Example', 'Taobao', 'Baidu']
list2 = list1.copy()
print ("list2 list: ", list2)
The output of the above example is:
list2 列表: ['Google', 'Example', 'Taobao', 'Baidu']Other Extensions
Python3 Lists