In this article, you’ll see how to count an element in a list in Python. The count method is used to find how many times an element occurs in the list. The count method takes only one argument. The argument is the element that you want to count. I highly recommend you get the “Python Crash Course Book” to learn Python.
Example: Count 5 in the list
In the given example, we will find how many times the number 5 occurs in the list.
a = [5, 10, 5, 20, 30] print(a.count(5))
Output:
2