Counting number of each item in a list.

sophie_newbie paulgeeleher at gmail.com
Sun Mar 19 08:23:50 EST 2006


Hey Bruno,

I got an invalid syntax error when i tried using your "str_counts =
dict((s, str_list.count(s) for s in set(str_list))" bit of code? Maybe
there is a missing bracket or comma? Or maybe I need to import
something.

Thanks so much for your help.




More information about the Python-list mailing list