Python List count() Method Tutorial

Python list contains multiple items in a single variable. These items' values can be the same or different. The List count() method is provided by all list types in order to count the specified value.

List count() Syntax

The list count() method has the following syntax where it accepts single parameter which is required.

LIST.count(VALUE)
  • LIST is the list where the search will done.
  • VALUE is the value or variable which will be searched in LIST.

Count Specified Value In List

In the following example we will find the count of the value "ismail" in the list anmed "names".

names = ["ismail","ahmet","ali","ismail","ahmet","ismail"]

count = names.count("ismail")

print(count)

The count() method is provided for list type even the list is not a variable. In the following example we will call the count() method for list value.

count = ["ismail","ahmet","ali","ismail","ahmet","ismail"].count("ismail")

print(count)

The output will be like below which is the count of the "ismail".

3

Leave a Comment