I have a list of lists like the below:
lst = [['A', 2001, ...], ['A', 2001, ...], ['B', 2001, ...], ['A', 2002, ...], ['C', 2002, ...], ...]
I would like to iterate over the combinations of a zipped list between the first two elements of each inner list, excluding duplicates.
I could do the below, but it doesn't exclude duplicates.
letters = [item[0] for item in lst]
years = [item[1] for item in lst]
for letter, year in zipped(letters, years):
In this example, the pairs that I am looking to iterate over would be:
'A': 2001
'B': 2001
'A': 2002
'C': 2002
(Note the exclusion of the additional 'A':2001
pair)
I feel that my attempted code is more complicated than it needs to be. ANy ideas are much appreciated.