Constantly checking existence of dictionary elements in Python: a better way?
For Python >= 2.5 you can use defaultdict instead of dict:

 from collections import defaultdict
 words = defaultdict(int)
 corpus = ["your", "word", "corpus"]
 for a in corpus:
    words[a]+=1
 print words


For Python >= 2.7 you can use Counter:

from collections import Counter
corpus = ["your", "word", "corpus"]
words = Counter(corpus)
print words