I have a list of tuples of the form:
list = [('A',2),('A',1),('B',3),('A',4),('B',5),('A',1)]
And I want two lists, one with all the tuples with first element 'A' and the other with tuples with first element 'B'.
listA = [('A',2),('A',1),('A',4),('A',1)]
listB = [('B',3),('B',5)]
Any ideas? Thank you! EDIT : Note that the list above is just as an example, my actual list is much longer and has 100+ different first elements.