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
Using count() method, pass the item to be counted. As shown above, 'a' is passed, which gives the total number of occurrences of character 'a'.
You can learn more about count() at Python count().
Related posts:
Python String istitle()
Python Program to Swap Two Variables
Python range()
How to Get Started With Python?
Python Program to Make a Simple Calculator
Intelligent Projects Using Python - Santanu Pattanayak
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli
Python slice()
Python ord()
Python Set discard()
Python staticmethod()
Python float()
Python Directory and Files Management
Python enumerate()
Python classmethod()
Python Tuple index()
Python input()
Python Global, Local and Nonlocal variables
Python String isnumeric()
Building Machine Learning Systems with Python - Willi Richert & Luis Pedro Coelho
Python List clear()
Python String maketrans()
Python Dictionary copy()
Python String split()
Python pow()
Python memoryview()
Python Function Arguments
Python Set copy()
Python Program to Calculate the Area of a Triangle
Python Program to Check if a Number is Odd or Even
Python String center()
Python Program to Merge Mails