What is List Copy() Method?
The list Copy() function in Python is used to create a copy of a list. There are two main ways to create a copy of the list Shallow copy and Deep copy. We will discuss the list copy() method in detail below.
The list copy() function is used to create a copy of a list, which can be used to work and it will not affect the values in the original list. This gives freedom to manipulate data without worrying about data loss.
Python List copy() Method
The list Copy() method makes a new shallow copy of a list.
Example
Python3
# Using list fruits fruits = [ "mango" , "apple" , "strawberry" ] # creating a copy shakes shakes = fruits.copy() # printing shakes list print (shakes) |
['mango', 'apple', 'strawberry']