Use defaultdict(int) instead of checking and assigning