I had two tuple of tuples ("one" and "two") and I need to join them. If the subelements of the first tuple(for example, one[0]) in the positions 1, 2, 3, 4 and 5 are equal to the first five elements in the tuple two (for example if one[0][0] == two[0][0] and one[0][1] == two[0][1] ... and one[0][5] == two[0][5]), then they need to be combined:
one = (
(25, "sample", "x", "y", "z", 200, 50, 45),
)
two = (
(25, "other", "p", "q", "r", 0),
)
result = (
(25, "sample", "x", "y", "z", 200, 50, 0, 45),
)
For example, with this two tuples
one = (
(25, "sample", "x", "y", "z", 200, 50, 45),
(25, "other", "p", "q", "r", 100, 25, 0),
(27, "sample", "x", "y", "z", 200, 50, 45),
(28, "other", "p", "q", "r", 100, 25, 0),
)
two = (
(1, "sample", "x", "y", "z", 45),
(25, "other", "p", "q", "r", 0),
(27, "sample", "x", "y", "z", 20),
(28, "other", "p", "q", "r", 1),
)
The result needs to be something like this (it could be a list of list, a list of dicts or just a tuple of tuples:
result = (
(1, "sample", "x", "y", "z", 0, 0, 45, 0),
(25, "sample", "x", "y", "z", 200, 50, 0, 45),
(25, "other", "p", "q", "r", 100, 25, 0, 0),
(27, "sample", "x", "y", "z", 200, 50, 20, 45),
(28, "other", "p", "q", "r", 100, 25, 1, 0),
)
I don't know if the best way is to change this tuples for lists or maybe iterate each tuples and add each element as a list in a new one.