I want to know if there is any efficient way to convert a list containing tuples of a two-item tuple and a single item into a flattened list or NumPy array?
list = [((-1, -1), -1), ((-1, -1), 0), ((-1, -1), 1), ((-1, -1), 2), ...]
The result I want is:
new_list = [[-1, -1, -1], [-1, -1, 0], [-1, -1, 1], [-1, -1, 2], ...]
So far, I have tried to use
new_list = [item for i in list for item in i]
But the result is comes out as:
[(-1, -1), -1, (-1, -1), 0, (-1, -1), 1, (-1, -1), 2, ...]
When I tried to remove the nested tuple, I got the error
TypeError: 'int' object is not iterable