if word_dict.has_key(word): # To if word in word_dict: word_dict.iteritems() # To word_dict.items() f = open('Alice.txt', 'rU') # To f = open('Alice.txt')A example of more modern Python power

This one is also more accurate,as it remove punctuation(as should be done when count larger text).
from collections import Counter import re with open('alice.txt') as f: text = f.read().lower() words = re.findall('\w+', text) top_10 = Counter(words).most_common(10) for word,count in top_10: print(f'{word:<4} {"-->":^4} {count:>4}')
Output:the --> 1818
and --> 940
to --> 809
a --> 690
of --> 631
it --> 610
she --> 553
i --> 543
you --> 481
said --> 462