How does deleting the words you just reported walk you down the frequency ranking — and what does that cost the caller?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
A short chant has already been counted into this frequency dictionary:
counts = {'sun': 4, 'moon': 7, 'sky': 2, 'star': 7, 'sea': 5}
Assign to highest the largest frequency in it — the number, not the word. Work it out from the dictionary rather than typing the number you can see with your eyes. Two pieces are all you need: the dictionary method that hands back every value, and max.
find_frequent_word and ties at the maximum
Write highest = max(word_dict.values()), loop over .items() appending into a list every key whose value equals highest, and trace the song dictionary to (['ah', 'mah'], 3).
The delete-and-repeat loop in occurs_often
Write the while loop that calls find_frequent_word again inside the body, appends its tuple, and dels each word it reported, then trace x = 2 to [(['ah', 'mah'], 3), (['rah'], 2)].
The boundary case at x = 2
Record that the loop still appends (['rah'], 2) although 2 is not strictly greater than 2, and that >= would run one more round and add (['rom', 'ro'], 1).
The side effect on the caller's dictionary
State that occurs_often leaves the caller's frequency dictionary stripped of its most frequent entries, and note that the same task can be written without mutating anything.