I have list of 2-elements tuples:
[(7, 3), (4, 3), (5, 3), (6, 3), (0, 1), (1, 1), (2, 1), (3, 1)]
And I want to convert it to another list of tuples. Each list contains elements with the same second index from first list.
So in this case result should look:
[(7, 4, 5, 6), (0, 1, 2, 3)]
because 7, 4, 5, and 6 are paired with 3 while 0, 1, 2, 3 are paired with 1.
My attempt is to do it this way:
x = list(map(operator.itemgetter(0), sorted_countries))
but I still don't know how to group it, because my result is:
[7, 4, 5, 6, 0, 1, 2, 3]