For reasons I never quite understood python has a collections.Counter for the purpose of counting things. It's a bit cleaner.