Counter for items in lists in lists?

Charlotte Henkle charlotte at fgm.com
Sat Sep 25 02:17:32 EDT 2004


Hello;

I'm pondering how to count the number of times an item appears in
total in a nested list.  For example:

myList=[[a,b,c,d],[a,f,g,h],[a,b,x,y]]

I'd like to know that a appeared three times, and b appeared twice,
and the rest appeard only once.

Every solution I've touched on so far has seemed clumsy.  Does anyone
have any thoughts for a down and dirty solution to this?

Many thanks...

/Charlotte



More information about the Python-list mailing list