---
description: Python count The count() is a built-in function in Python. It will return the total count of a given element in a list. The count() function is used to count elements on a list as well as a string. In
title: Python List count() with EXAMPLES
image: https://www.guru99.com/images/python-list-count.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

The Python count() method returns how many times a given element appears in a list or string. Here you will learn its syntax, see examples on lists and strings, and count all elements at once with Counter.

* 🔢 **What it does:** count() returns how many times an element appears in a list.
* 📝 **Syntax:** list.count(element) takes the element to count as its argument.
* 🚫 **Not found:** count() returns 0 when the element is not in the list.
* 🔤 **Strings too:** count() also counts characters or substrings in a string.
* 🤖 **AI help:** AI tools like Copilot generate counting code instantly.

[ Read More ](javascript:void%280%29;) 

![Python List Count](https://www.guru99.com/images/python-list-count.png)

## Python count

The count() is a built-in function in Python. It will return the total count of a given element in a list. The count() function is used to count elements on a list as well as a string.

## Python List count()

The count() is a built-in function in [Pyhton](https://www.guru99.com/python-tutorials.html). It will return you the count of a given element in the list.

### Syntax

list.count(element)

### Parameters

**element**: The element you want to find the count.

### ReturnValue

The count() method will return an integer value, i.e., the count of the given element from the given list. It returns a 0 if the value is not found in the given list.

## Example 1: List Count

Following example shows the working of count() function on a list:

list1 = ['red', 'green', 'blue', 'orange', 'green', 'gray', 'green']
color_count = list1.count('green')
print('The count of color: green is ', color_count)

**Output:**

The count of color: green is  3

## Example 2: Find the count of elements (Duplicates) in a givenlist

list1 = [2,3,4,3,10,3,5,6,3]
elm_count = list1.count(3)
print('The count of element: 3 is ', elm_count)

**Output:**

The count of element: 3 is  4

## Count Characters in a String

The count() method also works on strings, returning how many times a character or substring appears.

message = "hello world"
print(message.count("l"))
print(message.count("o"))

**Output:**

3
2

### RELATED ARTICLES

* [Python Conditional Statements: IF…Else, ELIF & Switch Case ](https://www.guru99.com/if-loop-python-conditional-structures.html "Python Conditional Statements: IF…Else, ELIF & Switch Case")
* [Django Tutorial: Features, Architecture & History ](https://www.guru99.com/django-tutorial.html "Django Tutorial: Features, Architecture & History")
* [Python vs JavaScript: Key Difference Between Them ](https://www.guru99.com/python-vs-javascript.html "Python vs JavaScript: Key Difference Between Them")
* [How to Run Python Scripts: Step by Step Guide ](https://www.guru99.com/run-python-scripts.html "How to Run Python Scripts: Step by Step Guide")

## Count All Elements Using Counter

To count every element at once instead of one at a time, use Counter from the collections module.

from collections import Counter

list1 = ["red", "green", "blue", "green", "red", "green"]
print(Counter(list1))

**Output:**

Counter({'green': 3, 'red': 2, 'blue': 1})

This code is editable. Click Run to Execute   

  
## FAQs

🔢 What does the count() method do in Python?

count() returns the number of times a given element appears in a list. list.count(element) takes the element as its argument and returns an integer.

🚫 What does count() return if the element is missing?

count() returns 0 when the element is not present in the list. It never raises an error for a missing value.

🔤 Can you use count() on a string?

Yes. string.count(substring) returns how many times a character or substring appears in a string, working the same way as it does on a list.

🔁 How do you count all elements in a list at once?

Use collections.Counter, which returns a dictionary of each element and its count in one call, instead of calling count() for every element.

🆚 What is the difference between count() and Counter?

count() counts one element at a time, while collections.Counter counts every element in a single pass, which is faster when you need all counts.

🤖 How can AI tools like GitHub Copilot help count list items?

AI assistants like GitHub Copilot autocomplete count() and Counter calls, and generate loops or comprehensions that tally elements from a short description.

🧠 Can AI automate counting logic in Python?

Yes. AI-powered tools can automate writing counting and frequency code, suggest Counter over manual loops, and refactor slow tallies into efficient one-liners.

🔡 Is count() case-sensitive for strings?

Yes. count() treats uppercase and lowercase as different, so ‘A’ and ‘a’ are counted separately. Convert the text with lower() first for case-insensitive counts.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/python-list-count.png","url":"https://www.guru99.com/images/python-list-count.png","width":"700","height":"250","caption":"Python List count()","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/python-list-count.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/python","name":"Python"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/python-list-count.html","name":"Python List count() with EXAMPLES"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/python-list-count.html#webpage","url":"https://www.guru99.com/python-list-count.html","name":"Python List count() with EXAMPLES","dateModified":"2026-07-11T10:43:15+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/python-list-count.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/python-list-count.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/anna","name":"Anna Blake","description":"I'm Anna Blake, specializing in Python tutorials, offering clear and concise lessons to help you master Python programming efficiently.","url":"https://www.guru99.com/author/anna","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/anna-blake-author.png","url":"https://www.guru99.com/images/anna-blake-author.png","caption":"Anna Blake","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"Python","headline":"Python List count() with EXAMPLES","description":"Python count The count() is a built-in function in Python. It will return the total count of a given element in a list. The count() function is used to count elements on a list as well as a string. In","keywords":"python","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/anna","name":"Anna Blake"},"dateModified":"2026-07-11T10:43:15+05:30","image":{"@id":"https://www.guru99.com/images/python-list-count.png"},"copyrightYear":"2026","name":"Python List count() with EXAMPLES","subjectOf":[{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What does the count() method do in Python?","acceptedAnswer":{"@type":"Answer","text":"count() returns the number of times a given element appears in a list. list.count(element) takes the element as its argument and returns an integer."}},{"@type":"Question","name":"What does count() return if the element is missing?","acceptedAnswer":{"@type":"Answer","text":"count() returns 0 when the element is not present in the list. It never raises an error for a missing value."}},{"@type":"Question","name":"Can you use count() on a string?","acceptedAnswer":{"@type":"Answer","text":"Yes. string.count(substring) returns how many times a character or substring appears in a string, working the same way as it does on a list."}},{"@type":"Question","name":"How do you count all elements in a list at once?","acceptedAnswer":{"@type":"Answer","text":"Use collections.Counter, which returns a dictionary of each element and its count in one call, instead of calling count() for every element."}},{"@type":"Question","name":"What is the difference between count() and Counter?","acceptedAnswer":{"@type":"Answer","text":"count() counts one element at a time, while collections.Counter counts every element in a single pass, which is faster when you need all counts."}},{"@type":"Question","name":"How can AI tools like GitHub Copilot help count list items?","acceptedAnswer":{"@type":"Answer","text":"AI assistants like GitHub Copilot autocomplete count() and Counter calls, and generate loops or comprehensions that tally elements from a short description."}},{"@type":"Question","name":"Can AI automate counting logic in Python?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI-powered tools can automate writing counting and frequency code, suggest Counter over manual loops, and refactor slow tallies into efficient one-liners."}},{"@type":"Question","name":"Is count() case-sensitive for strings?","acceptedAnswer":{"@type":"Answer","text":"Yes. count() treats uppercase and lowercase as different, so 'A' and 'a' are counted separately. Convert the text with lower() first for case-insensitive counts."}}]}],"@id":"https://www.guru99.com/python-list-count.html#schema-1140609","isPartOf":{"@id":"https://www.guru99.com/python-list-count.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/python-list-count.html#webpage"}}]}
```
