List count(obj) Method

In Python Built-In List count(obj) method is used to returns the count of how many times obj occurs in the given list.

Syntax:
There is 1 Parameter used in list count(obj) method: obj Shows the object to be counted in the list.
Example:
#method

list1 = ['BOB', 'TOM', 'JOHN', 'BOB']
print ("Count for TOM : ", list1.count('TOM'))
print ("Count for BOB : ", list1.count('BOB'))

Comments are closed.