Python Program to Count Occurrences of Items in a Python List Using Comprehension
# Count the Occurrence of an Item in a List Using comprehension in python lis = ['a', 'd', 'd', 'c', 'a', 'b', 'b', 'a', 'c', 'd', 'e'] occurrence = {item: lis.count(item) for item in lis} print(occurrence.get('d'))
Output:
3