In Python it\'s annoying to have to check whether a key is in the dictionary first before incrementing it:
if key in my_dict: my_dict[key] += num else: m
What you want is called a defaultdict
See http://docs.python.org/library/collections.html#collections.defaultdict