1 from collections import Counter 2 colours=( 3 ('Yasoob','Yellow',1), 4 ('Ali','Blue',2), 5 ('Arham','Green',3), 6 ('Ali','Black',4), 7 ('Yasoob','Red',5), 8 ('Ahmed','Silver',6), 9 ('Ahmed','Red',7), 10 ) 11 12 favs = Counter((name,colour) for name, colour,value in colours) 13 unions=Counter(name for name, colour,value in colours) 14 print(favs) 15 print(unions)