Python3 List copy () method
description
copy () function is used to copy a list, similar toa [:].
grammar
copy () method syntax:
list.copy()
parameter
- no.
return value
Returns a new list after copying.
Examples
The following examples show the copy () function to use:
#!/usr/bin/python3 list1 = ['Google', 'w3big', 'Taobao', 'Baidu'] list2 = list1.copy() print ("list2 列表: ", list2)
Examples of the above output results are as follows:
list2 列表: ['Google', 'w3big', 'Taobao', 'Baidu']