# Make a dict of all the words in the file # Count the number of times each word occurs word_dict = {} silly_file = open("silly.txt", "r") for line in silly_file: word_list = line.split() for word in word_list: if word in word_dict: # Word is already present in the dict word_dict[word] = word_dict[word] + 1 else: # Seeing the word for the first time word_dict[word] = 1 silly_file.close() print(word_dict)