Table of Contents
show
Program Code
def frequency(list):
unique_list = set(list)
for item in unique_list:
print(item, ":", list.count(item))
list = [1, 2, 3, 1, 2, 3, 2, 2, 4, 5, 5]
frequency(list)
Code Explanation
- We first create a set of the list. A set is a collection of unique items.
- We then loop through the set and print the item and the number of times it occurs in the list.