Interview Query

Word Frequency

Have you seen this question before?

You’re hired by a literary newspaper for an unusual project. They want you to use your data science skills to parse the most frequent words used in poems.

Poems are given as a list of strings called sentences. Return a dictionary of the frequency that words are used in the poem.

Your keys should be a number representing the number of times the word is used in the poem, with its value being a list of words with that frequency.

Make sure to process all words as entirely lowercase. Additionally, do not worry about parsing punctuation marks.



sentences = [
  "I love roses",
  "Roses are the best",
  "Roses are red violets are blue"


def word_frequency(sentences) -> {
Next question: Third Party Ad Pricing
Python 3.9.6
Loading editor
Use Shift + Enter to run code