Answer:
The program in Python is as follows:
def count_occur(myList):
freq = {}
for item in myList:
if item in freq:
freq[item] += 1
else:
freq[item] = 1
for item in freq:
print(item," ",freq[item])
Explanation:
This gets the list from the main
def count_occur(myList):
This initializes an empty dictionary
freq = {}
This iterates through the list and count the occurrence of each item
for item in myList:
if item in freq:
freq[item] += 1
else:
freq[item] = 1
This iterates through the dictionary
for item in freq:
This prints each dictionary item and the frequency separated by -
print(item," ",freq[item])