- countOf() is a python in-build function which count the occurance of item in sequence.
- this function is predefined in operator module.
Syntax-
operator.countOf(seq,item)
-Here seq is sequence, i.e. list,tuple etc
-It return the occurance of the item in the sequnece.
Example-
list is :[1,2,3,1,1,1]
operator.contains(list,2) will return 1
operator.contains(list,3) will return 4
operator.contains(list,8) will return 0
program-
import operator
l=[1,2,2,2,3,1,1,1,1,1,1,'a','a']
print(operator.countOf(l,8))
print(operator.countOf(l,2))
print(operator.countOf(l,1))
print(operator.countOf(l,3))
print(operator.countOf(l,9))
print(operator.countOf(l,10))
print(operator.countOf(l,'a'))
0
3
7
1
0
0
2