Q:

Write a Python program to count the occurrence of each element of a given list.

0

Write a Python program to count the occurrence of each element of a given list.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

from collections import Counter
colors = ['Green', 'Red', 'Blue', 'Red', 'Orange', 'Black', 'Black', 'White', 'Orange']
print("Original List:")
print(colors)
print("Count the occurrence of each element of the said list:")
result = Counter(colors)
print(result)
nums = [3,5,0,3,9,5,8,0,3,8,5,8,3,5,8,1,0,2]
print("\nOriginal List:")
print(nums)
print("Count the occurrence of each element of the said list:")
result = Counter(nums)
print(result)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now