Easy Tutorial
❮ Ref Math Isnan Python Random ❯

Python3 List count() Method

Python3 List


Description

The count() method is used to count the number of times an element appears in the list.

Syntax

The syntax for the count() method is:

list.count(obj)

Parameters

Return Value

Returns the number of times the element appears in the list.

Example

The following example demonstrates the use of the count() function:

#!/usr/bin/python3

aList = [123, 'Google', 'tutorialpro', 'Taobao', 123];

print ("Count of 123 : ", aList.count(123))
print ("Count of tutorialpro : ", aList.count('tutorialpro'))

The output of the above example is:

Count of 123 :  2
Count of tutorialpro :  1

Python3 List

❮ Ref Math Isnan Python Random ❯