In the previous article, we have seen how to clone or Copy a list, now let’s see how to copy a nested list in Python.
Method #1: Using Iteration
Initial list is: [[0, 1, 2], [3, 4, 5]] New assigned list is [[0, 1, 2], [3, 4, 5]]
Method #2: Using deepcopy
Initial list is: [[1, 0, 1], [1, 0, 1]] New assigned list is [[1, 0, 1], [1, 0, 1]]
Method #3: Using list comprehension and slicing
Initial list is: [[0, 1, 2], [3, 4, 5], [0, 1, 8]] New assigned list is [[0, 1, 2], [3, 4, 5], [0, 1, 8]]
- Python | Check if a nested list is a subset of another nested list
- Python | Pair and combine nested list to tuple list
- Python | Find maximum length sub-list in a nested list
- Python | Convert a nested list into a flat list
- Python | Convert given list into nested list
- Nested List Comprehensions in Python
- Python | Intersection of two nested list
- Python | Remove duplicates from nested list
- Python | Remove all occurrences in nested list
- Python | Split nested list into two lists
- Python | Find the sublist with maximum value in given nested list
- Python | Remove all duplicates and permutations in nested list
- Python | Convert list of nested dictionary into Pandas dataframe
- Python list | copy() method
- copy in Python (Deep Copy and Shallow Copy)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.