Counter() Provides an Easy Way to Count How Many Items of Each Type Are In Python Collection Objects
Counter is a member of the collections module. You can give Counter() any iterator, and it will return a hashmap (like a dictionary) with the counts.