Your question is Find Top N Word Frequencies. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Warner Music Group can analyze words appearing in music catalog metadata and editorial text. Given a string and an integer n, return the n most frequently occurring words.
Implement top_words(text, n). Treat words as contiguous sequences of English letters A-Z, ignoring case and all other characters. Return a list of lowercase words ordered by decreasing frequency. If two words have the same frequency, order them alphabetically. Return fewer than n words when the text contains fewer distinct words. If n is zero or the text contains no words, return an empty list.
def top_words(text, n):