I have the following code:
list1 = [('a', 0), ('b', 100), ('c', 200), ('d', 300), ('e', 400), ('f', 500)]
list2 = [[0, 200, 400], [100, 300, 500]]
list2
just basically reorganizes the numbers into teams, the 2 sublists.
My list3
would then be:
list3 = [['a', 'c', 'e'], ['b', 'd', 'f']]
So by looking up the values in list2
in list1
, what code do I need to produce list3
?
This is also valid:
list1 = [('a', 0), ('b', 0), ('c', 0), ('d', 0), ('e', 0), ('f', 0)]
list2 = [[0, 0, 0], [0, 0, 0]]
It would give:
list3 = [['a', 'b', 'c'], ['d', 'e', 'f']]
So basically 'a'
and 'f'
could have the same value but they can only return once in list3