[Tutor] Detecting different list elements and counting them
Michael Grabietz
michael.grabietz at img-online.de
Thu Dec 11 10:13:35 EST 2003
Hi,
I have a list like the following:
my_list = [ 'ABC', 'E', 'ABC', 'ABC', 'HJ', 'HJ' ]
It would be nice to have the information which elements are in the list
and how many times these elements appear in the list.
A dictionary as the result like the following would be fine.
my_dict = {'ABC':3, 'E':1, 'HJ':2}
Thank you for any ideas or hints.
Michael
More information about the Tutor
mailing list