# Python List copy()

In this tutorial, we will see about Python List‘s copy method.Python List clear method is used to shallow copy the list.

## Python List copy example

You can simply use copy method to shallow copy the list.It returns shallow copy of the list.
Let’s understand this with the help of simple example.

``` listOrig=l=[1,2,3,4] listCopy=listOrig.copy() listCopy.append(5) print("Original List:",listOrig) print("Copied list:",listCopy) print("List after clear:",l) ```

Output:

Original List: [1, 2, 3, 4]
Copied list: [1, 2, 3, 4, 5]

As you can see change in copied list does not original list.
Let’s understand now, what is meant by shallow copy here.

``` listOrig=[['one','two'],['four','five']] listCopy=listOrig.copy() listCopy.append('three') print("Original List:",listOrig) print("Copied list:",listCopy) ```

Output:

Original List: [[‘one’, ‘two’, ‘three’], [‘four’, ‘five’]]
Copied list: [[‘one’, ‘two’, ‘three’], [‘four’, ‘five’]]

As you can see here, change in inner list affected both the list.As when you use list’s copy method, it is actually shallow copy, so changes in inner list will impact both the list.
That’s all about Python List copy method.

## Related Posts

• 21 December

### Matrix multiplication in Python using user input

Learn about how to Matrix multiplication in Python using user input.

• 18 November

### How to print Array in Python

In this post, we will see how to print array in Python. As we know that, Python didn’t have an in-built array data type, so we try to use list data type as an array. We can also use the NumPy module for creating NumPy array and apply array operation on it. Now, we will […]

• 21 April

### Remove first element from list in Python

In this post, we will see how to remove the first element from a list in python. Using list.pop() We can use list.pop() method to remove the first element from the list. Output: List Of Fruits are: [‘Orange’, ‘Apple’, ‘Grapes’, ‘Mango’] List Of Fruits after removing first element: [‘Apple’, ‘Grapes’, ‘Mango’] Removed Fruit: Orange pop […]

• 26 March

### Find average of list in Python

There are multiple ways to find the average of the list in Python. Using sum() and len() We can use sum() to find sum of list and then divide it with len() to find average of list in Python. Here is the quick example of the same. [crayon-600d624a2bfa9024814997/] Output: Average of listOfIntegers: 3.0 Using reduce(), […]

• 22 December

### Python list of lists

In this post, we will see how to create a list of lists in python. It is quite easy to create list of lists in Python. You just need to use list’s append method to create list of lists. Here is simple example to create list of lists in Python. Output: List of Lists: [[1, […]

• 21 December

### Combine two lists in Python

In this tutorial, we will see how to combine two

## Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.