Join our newsletter for the latest updates.

Python Program to Count the Occurrence of an Item in a List

In this example, you will learn to count the occurrence of an item in a list.

To understand this example, you should have the knowledge of the following Python programming topics:


Using count() method

freq = ['a', 1, 'a', 4, 3, 2, 'a'].count('a')
print(freq)

Output

3

The above code prints the number of occurrences of 'a' in the list.

You can learn more about count() at Python count().