Multi dimensional arrays in Python of a dynamic size
In python there is no need to declare list size on forehand.
an example of reading lines to a file could be this:
file_name = "/path/to/file"
list = []
with open(file_name) as file:
file.readline
if criteria:
list.append(line)
For multidimensional lists. create the inner lists in a function on and return it to the append line. like so:
def returns_list(line):
multi_dim_list = []
#do stuff
return multi_dim_list
exchange the last row in the first code with
list.append(returns_list(line))
Nest lists in lists you don't need to predefine the length of a list to use it and you can append on to it. Want another dimension simply append another list to the inner most list.
[[[a1, a2, a3] , [b1, b2, b3] , [c1, c2, c3]],
[[d1, d2, d3] , [e1, e2, e3] , [f1, f2, f3]]]
and to use them easily just look at Nested List Comprehensions