Count each unique element in list of lists

yasar11732 at gmail.com yasar11732 at gmail.com
Fri Nov 8 20:38:10 CET 2013


This works;

>>> for result in results:
	flat = list(item for group in result for item in group)
	print [sum([1 for el in flat if el==current]) for current in flat]

	
[1, 1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1, 1]

But I am still open to suggestions if anyone thinks this can be improved.



More information about the Python-list mailing list