I have a list new_l_2 = [['0', '0', '10'], ['0', '2', '30'], ['1', '1', '20']]
and a list of lists matrix = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
and when I execute
for i in new_l_2:
matrix[int(i[0])][int(i[1])] = i[2]
I get [['10', '20', '30'], ['10', '20', '30'], ['10', '20', '30']]
but my wanted output is [[10.0, 0.0, 30.0], [0.0, 20.0, 0.0], [0.0, 0.0, 0.0]]
where the first element of the first sublist of new_l_2 is the sublist of matrix wanted and the second element of the first sublist of new_l_2 is the position inside the sublist of matrix in which I put the third element of the first sublist of new_l_2. What am I missing here ?
matrix was created via
matrix = []
li = []
for i in range(lignes):
li.append(0.0)
for i in range(colonnes):
matrix.append(li)