# Count the number of words in a text file and # make a dict of all the words in the file word_dict = dict() silly_file = open("silly.txt", "r") for line in silly_file: #print line, word_list = line.split() print word_list for word in word_list: if word in word_dict: word_dict[word] += 1 else: word_dict[word] = 1 silly_file.close() print word_dict