Copyright © tutorialspoint.com

Python List count() Method

previous next


Description:

This method returns count of how many times obj occurs in list.

Syntax:

list.count(obj)

Parameters:

Here is the detail of parameters:

Return Value:

It returns count of how many times obj occurs in list.

Example:

#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc', 123];

print "Count for 123 : ", aList.count(123);
print "Count for zara : ", aList.count('zara');

This will produce following result:

Count for 123 :  2
Count for zara :  1

previous next

Copyright © tutorialspoint.com