Re: Count each unique element in list of lists

2013-11-08 Thread Vlastimil Brom
2013/11/8 Yaşar Arabacı : > Hi, > > I have a function that returns something like this; > > [[[1, 5, 9], [2, 6, 7], [3, 4, 8]], [[1, 6, 8], [2, 4, 9], [3, 5, 7]]] > > It is a list of list of lists. Each uppermost list is called a result. > I want to write a code that > shows that each elem in subli

Re: Count each unique element in list of lists

2013-11-08 Thread Chris Angelico
On Sat, Nov 9, 2013 at 6:28 AM, Yaşar Arabacı wrote: > I want to write a code that > shows that each elem in sublists of result on appears once in whole > sublist in order to add it to > my doctest. So, to clarify the problem: You want to ensure that every element occurs exactly once, neither mor

Re: Count each unique element in list of lists

2013-11-08 Thread yasar11732
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 t

Count each unique element in list of lists

2013-11-08 Thread Yaşar Arabacı
Hi, I have a function that returns something like this; [[[1, 5, 9], [2, 6, 7], [3, 4, 8]], [[1, 6, 8], [2, 4, 9], [3, 5, 7]]] It is a list of list of lists. Each uppermost list is called a result. I want to write a code that shows that each elem in sublists of result on appears once in whole su