the most common words coming back to our running example of the text from romeo and juliet act scene we can augment our program to use this technique to print the ten most common words in the text as followsimport string fhand open('romeo-full txt'counts dict(for line in fhandline line translate(str maketrans(''''string punctuation)line line lower(words line split(for word in wordsif word not in countscounts[word elsecounts[word+ sort the dictionary by value lst list(for keyval in list(counts items())lst append((valkey)lst sort(reverse=truefor keyval in lst[: ]print(keyvalcodethe first part of the program which reads the file and computes the dictionary that maps each word to the count of words in the document is unchanged but instead of simply printing out counts and ending the programwe construct list of (valkeytuples and then sort the list in reverse order since the value is firstit will be used for the comparisons if there is more than one tuple with the same valueit will look at the second element (the key)so tuples where the value is the same will be further sorted by the alphabetical order of the key at the end we write nice for loop which does multiple assignment iteration and prints out the ten most common words by iterating through slice of the list (lst[: ]so now the output finally looks like what we want for our word frequency analysis and romeo to the