""" Counting unique words, and the frequencies of words, from the text stored in a specific file. Main problem observed here: the output is hard to read. """ in_file = open("file1.txt", "r") # initialize the dictionary to empty dictionary = {} for line in in_file: words = line.split() for word in words: if (word in dictionary): dictionary[word] += 1 else: dictionary[word] = 1 print() for word in dictionary: frequency = dictionary[word] print(word + ":", frequency) print()