THE WORLD'S LARGEST WEB DEVELOPER SITE

Python List count() Method

❮ List Methods


Example

Return the number of times the value "cherry" appears int the fruits list:

fruits = ['apple', 'banana', 'cherry']

x = fruits.count("cherry")
Run example »

Definition and Usage

The count() method returns the number of elements with the specified value.


Syntax

list.count(value)

Parameter Values

Parameter Description
value Required. Any type (string, number, list, tuple, etc.). The value to search for.

More Examples

Example

Return the number of times the value 9 appears int the list:

points = [1, 4, 2, 9, 7, 8, 9, 3, 1]

x = points.count(9)
Run example »

❮ List Methods