Copyright © tutorialspoint.com
This method returns count of how many times obj occurs in list.
list.count(obj) |
Here is the detail of parameters:
obj: object to be counted in the list.
It returns count of how many times obj occurs in list.
#!/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 |
Copyright © tutorialspoint.com