Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Count frequency of items in a list using defaultdict
from collections import defaultdict
some_data = ['a','b','v','c','l','c']
frequency_count = defaultdict(int)
for item in some_data:
frequency_count[item] += 1
print frequency_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.