Input:
I have this ordered list.
[[1, 'A'], [1, 'B'],[1, 'D'], [2, 'A'],[2,'D'], [3, 'C'], [4, 'D'], [5, 'B'], [6, 'D']]
Desired output
[[1,['A','B','D']],[2, ['A','D']], [3, 'C'], [4, 'D'], [5, 'B'], [6, 'D']]
Since the first item of those two sublists are same.
Also can i convert into a dictionary with a key and those values pair. Like
{1:['A','B','D'],2:['A','D'],3:['C']}
What is the easiest and simplest way to do this?
[1, 'C']at the end of your outer list? Should that be grouped with the first two or not? This question is a bit underspecified.