Write a Python program to count the occurrence of each element of a given list.
- برمجة
- برمجة بايثون
- 2021-04-16
- salsabeelalhams99111801528
الأجوبة
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)أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال