I have multiple lists with coordinates:
x = [2423, 2342, 4432]
y = [532, 5432, 5432]
w = [7456, 256, 5645]
h = [2345, 6543, 8764]
I want to concatenate these lists so that the position of an item would correspond with the position of other items in a single list. You can think of it as a dataset for every item in x, y, w, h with the same position in the same list
for example:
Boxes = [
[x[0],y[0],w[0],h[0]],
[x[1],y[1],w[1],h[1]],
[x[2],y[2],w[2],h[2]],
]
Of course I would not write manually the position of an element for every list, but this shows what I want to achieve. Any help would be appreciated
After setting the coordinates dynamically, you can append them into the boxes one by one using the for loop with the length of the x. Please note length of all arrays should be the same.
x = [2423, 2342, 4432]
y = [532, 5432, 5432]
w = [7456, 256, 5645]
h = [2345, 6543, 8764]
Boxes = []
for i in range(len(x)):
Boxes.append([x[i], y[i], w[i], h[i]])
After this Boxes
value would be equal to that:
[[2423, 532, 7456, 2345], [2342, 5432, 256, 6543], [4432, 5432, 5645, 8764]]