Copy of multiple List

About copying List

Note when you don't want to use the standard library copy Because I don't want to import for just one time

In the case of one dimension

test1.py


list1 = [1, 2, 3]
list2 = list(list1)

In the case of two dimensions

test2.py


list1 = [[1, 2, 3], [4, 5, 6]]
list2 = map(list, list1)

In the case of 3D

test3.py


list1 = [[[1, 2], [3, 4]], [[5, 6], [7, 8] ]
list2 = map(lambda x: map(list, x), list1)

I think that it should be done recursively after the 4th dimension.

You can usually use the deepcopy of the standard librarycopy.

Recommended Posts

Copy of multiple List
[Python] Copy of multidimensional list
Copy of python
List of python modules
Multiple inheritance of classes
Copy of python preferences
[Introduction to Udemy Python 3 + Application] 19. Copy of list
Make a copy of the list in Python
List of activation functions (2020)
Depth of nested list
Display of fractions (list)
Quickly list multiple lines of text in your code
Sum of multiple numpy arrays (sum)
Summary of Python3 list operations
Catch multiple types of exceptions
Operation of filter (None, list)
Specify multiple list indexes (Python)
List of nodes in diagrams
List of self-made Docker images
Optimal placement of multiple images
Install multiple versions of Python
Multidimensional array initialization of list
List of useful coding styles
Extract multiple list duplicates in Python
[ev3dev × Python] Control of multiple motors
Judgment of if by list comprehension
List of ready-to-use word embed vectors
List of packages installed by conda
List of frequently used Linux commands
Delete multiple elements in python list
Generate a list of consecutive characters
About the basics list of Python basics
Note: List of customized special names
[Linux] List of Linux commands used in practice
Display a list of alphabets in Python 3
Algorithm Gymnastics 24 Middle of the Linked List
Get the column list & data list of CASTable
Install multiple versions of Polyphony using venv
[python] Get a list of instance variables
String conversion of a list containing numbers
Basic grammar of Python3 series (list, tuple)
Get out of multiple loops at once
List of Atom packages I really use
Summary of built-in methods in Python list
[Machine learning] List of frequently used packages
[Bash] Redirection of multiple lines to multiple files
Summary of how to use Python list
[Python] Get a list of folders only