Python Program to Count Occurrences of Items in a Python List Using countof()
# Count the Occurrence of an Item in a List Using countof() in python import operator as op # declaring the list l = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 3, 3] # driver program x = 4 print(f"{x} has occurred {op.countOf(l, x)} times")
Output:
4 has occurred 3 times