Python List count() method Last Updated : 27 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The count() method is used to find the number of times a specific element occurs in a list. It is very useful in scenarios where we need to perform frequency analysis on the data.Let's look at a basic example of the count() method. Python a = [1, 2, 3, 1, 2, 1, 4] c = a.count(1) print(c) Output3 Explanation: a.count(1) counts the occurrences of 1 in the list, as it is occurring 3 times in the list so the output is 3.Syntaxlist_name.count(value)Prameters:list_name: The list object where we want to count an element.value: The element whose occurrences need to be counted.Return Type: it an integer value, which represents the number of times the specified element appears in the list.Examples of count() methodExample 1: Lits Containing Different DatatypesThe count() method also works well with list that have different types of data. Python a = [1, 'GfG', 3.14, 'GfG', 1, True] c1 = a.count('GfG') c2 = a.count(1) print(c1) print(c2) Output2 3 Explanation:'GfG' appears twice.1 appears twice explicitly, but True is also counted because True == 1 in Python, making the total count three.Example 2: Count occurrence of sub-list in list of ListsThe count() method does not search within nested lists and it will only count occurrences at the top level. Python a = [1, [2, 3], 1, [2, 3], 1] c = a.count([2, 3]) print(c) Output2 Explanation: The sublist [2, 3] is treated as a single element in the list. The count() method counts it twice because it appears twice as a nested list.Example 3: Counting Word Frequency in a ListThis example simulates word analysis in a sentence by counting how often a word appears. Python s = "python is easy to learn and python is powerful".split() c1 = s.count("python") c2 = s.count("is") print(c1) print(c2) Outputcount of python: 2 count of is: 2 Explanation:.split() method splits the string into a list of words.We use count() to check how many times "python" and "is" appear.Related articles:Count occurrences of an element in a listHow to Get the Number of Elements in a Python List?Find all elements count in listFind most frequent element in a list Comment More info S Striver Follow Improve Article Tags : Misc Python python-list Python-Built-in-functions python-list-functions +1 More Explore Python FundamentalsPython Introduction 3 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 5 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 7 min read Python Functions 5 min read Recursion in Python 6 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 5 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 12 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 6 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 7 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 3 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like