from collections import counter mylist [ listcount counter(mylistprint(listcountfor thisitem in listcount items()print("item"thisitem[ ]appears"thisitem[ ]print("the value appears { times format(listcount get( ))in order to use the counter objectyou must import it from collections of courseif you work with other collection types in your applicationyou can import the entire collections module by typing import collections instead the example begins by creating listmylistwith repetitive numeric elements you can easily see that some elements appear more than once the example places the list into new counter objectlistcount you can create counter objects in all sorts of waysbut this is the most convenient method when working with list the counter object and the list aren' actually connected in any way when the list content changesyou must re-create the counter object because it won' automatically see the change an alternative to re-creating the counter is to call the clear(method first and then call the update(method to fill the counter object with the new data the application prints listcount in various ways the first output is the counter as it appears without any manipulation the second output prints the individual unique elements in mylist along with the number of times each element appears to obtain both the element and the number of times it appearsyou must use the items(function as shown finallythe example demonstrates how to obtain an individual count from the list using the get(function choose runrun module python shell window opensand you see the results of using the counter objectas shown in figure -