Skip to contentKEEP THE CRAFTTHE SANCTUARY

Count Word Frequencies

Turn a list of words into a dictionary from each word to how many times it appears.

The problem

Implement word_frequencies(words). words is a list of strings. Return a dictionary that maps each distinct word to the number of times it appears in the list. For example, ["red", "blue", "red"] gives {"red": 2, "blue": 1}, and an empty list gives an empty dictionary.

Starter code

def word_frequencies(words):
    pass

Public examples

  1. words = ["red", "blue", "red"]gives{"red": 2, "blue": 1}

Solving it in the practice book needs an active paid plan.

Open it in the practice book
One thought at a time.