Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python List count() Method


previous next AddThis Social Bookmark Button


Description:

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

Syntax:

list.count(obj)

Parameters:

Here is the detail of parameters:

  • obj: object to be counted in the list.

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 Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names