Python List copy()
In this tutorial, we will learn about the python list copy() method, which will return the copy of the given list.
Python List copy()
The syntax of the copy() method is:
1
new_list = my_list.copy()
copy() Parameters
The copy() method does not take any parameters as arguments.
Example 1 : How to use copy() method in python list?
1
2
3
4
5
6
7
8
9
my_list = [1,2,3,4,5]
print(my_list)
# copy list using copy() method
new_list = my_list.copy()
print(new_list)
The Output will be as follow.
1
2
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
Rule of list copy()
There are no such rules to implement the list copy() method.
This post is licensed under CC BY 4.0 by the author.