python dictionary count
count, dictionary, python
Solution
from collections import Counter
items = Counter(val[2] for val in dic.values())
Problem
I need to count the number of times different values are listed in my dictionary. The problem is that I cant figure out how to count the values. ``` print dic {'KLOI98': ['Martha Miller', '4563', 'Vet_Parking'], 'TY5678': ['Jane Miller', '8987', 'AgHort_Parking'], 'WER546': ['Olga Grey', '9898', 'Creche_Parking'], 'HUY768': ['Wilbur Matty', '8912', 'Creche_Parking'], 'EDF768': ['Bill Meyer', '2456', 'Vet_Parking'], 'DF7800': ['Jacko Frizzle', '4532', 'Creche_Parking'], 'JU9807': ['Jacky Blair', '7867', 'Vet_Parking'], 'GEF123': ['Jill Black', '3456', 'Creche_Parking'], 'ADF645': ['Cloe Freckle', '6789', 'Vet_Parking'], 'GH7682': ['Clara Hill', '7689', 'AgHort_Parking'], 'ABC234': ['Fred Greenside', '2345', 'AgHort_Parking']} ``` and my code: ``` for k, v in dic.items(): print "%s: %s" % (k, v) ``` All I'm trying to do is count the number of Vet,AgHort and Creche parks. I cant change the key as the rest of my script works with it. Thanks for the help. Should be simple, but I just cant crack it.