For loop assigning last value of list to entire 2D list.
I have this code:
for i in range(len(horiz_lines)):
for j in range(len(vert_lines)):
resultant = intersection(horiz_boxes[horiz_lines[i]], vert_boxes[vert_lines[ordered_boxes[j]]])
for b in range(len(boxes)):
the_box = [boxes[b][0][0],boxes[b][0][1],boxes[b][2][0],boxes[b][2][1]]
if iou(resultant,the_box)>0.1:
out_array[i][j]=texts[b]
print(out_array[i][j])
Now, functions are working fine, when I print out_array inside loop (as given in code), I get expected values. But once I call out_array in next cell and print it, values are changed. What mistake am I making?
Edit: Here is how out_array was created.
out_array = [["" for i in range(len(vert_lines))] for j in range(len(horiz_lines))]