Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Built-in Functions Common to Most Data Structures
8. count() – exercise
Summary

Instruction

Good job! How about one more exercise using count()?

Exercise

Write a function named get_frequency_dict(input_list) that accepts a list and returns a dictionary with list elements as keys and their counts as the corresponding values (i.e., the number of times each element appears in the list). E.g., for the following input:

[13, 43, 23, 13, 67, 67, 67, 11, 43]

The output should be:

{67: 3, 11: 1, 43: 2, 13: 2, 23: 1}

Stuck? Here's a hint!

Create a set with elements from the list and iterate over it. Each element should be the key and the outcome of the count() function should be the value.