If you want to access a list
or a array
with the operator [][]
, you just have to put a list within another list, in Python 2 and 3 you can do it in the same way:
# Suponiendo que N sean 10 items:
N = 10
# Creamos la lista de NxN listas.
matriz = list([ list([]) for i in range(0, N) ] for k in range(0, N))
matriz[1][2] = [ 345.545, 415.213 ]
print(matriz) # imprime la lista.
You should print:
[
[[], [], [], [], [], [], [], [], [], []],
[[], [], [345.545, 415.213], [], [], [], [], [], [], []],
[[], [], [], [], [], [], [], [], [], []],
[[], [], [], [], [], [], [], [], [], []],
[[], [], [], [], [], [], [], [], [], []],
[[], [], [], [], [], [], [], [], [], []],
[[], [], [], [], [], [], [], [], [], []],
[[], [], [], [], [], [], [], [], [], []],
[[], [], [], [], [], [], [], [], [], []],
[[], [], [], [], [], [], [], [], [], []]
]