Counting number of each item in a list.

sophie_newbie paulgeeleher at gmail.com
Sun Mar 19 07:41:33 EST 2006


I have a list a little something like this:

StringA
StringC
StringB
StringA
StringC
StringD
StringA
...
etc.

Basically I was wondering if there was an easy way to return how many
of each string are in the list, something like this:

StringA - 3
StringB - 1
StringC - 2
StringD - 1

I suppose that the easiest way to do that is to convert it to a 2
dimensional array? Is there any easy way?

Thanks.




More information about the Python-list mailing list