+ 3
A good way to create multidimensional arrays in python.
Multidimensional arrays don't seem to exist by default in Python like in other languages. So what is a good, pythonic way to create a N×N sized multidimensional list in python. For example, if N is 3, the list should be [[[], [], []], [[], [], []], [[], [], []]] You can view what I tried in this code of mine, about line 7 to 11 https://code.sololearn.com/cPBXqw3qDGqa/?ref=app But the way seems bad and unprofessional to me. What's a good, pythonic way to do the same?
4 Respostas
+ 8
The best would be to use the numpy module, which supports numpy.array class.
https://www.sololearn.com/learn/6671/?ref=app
https://www.sololearn.com/learn/6672/?ref=app
https://code.sololearn.com/ceNYYC1thqE6/?ref=app
https://code.sololearn.com/cWjC30xs7wRV/?ref=app
+ 4
Nope, just lists. Effectively, they can be used as arrays, but are more powerful (and less efficient), as they can store elements of mixed, any type of data, while arrays are monotyped.
+ 1
Thank you. numpy would work i guess but anything built in?
+ 1
hmmm... Thank you!