list.count() Count occurrences
Last updated: 2026-09-22
list.count() Count occurrences
list.count(x) counts occurrences of x.
| Category | List Methods |
|---|---|
| Kind | Built-in Type Method |
| Python Version | all |
📝 Syntax
list.count(x)
⚙️ Parameters
| x Required | The element whose occurrences are counted. |
|---|
Returns:int, the number of times x occurs in the list.
Mutates the original:No (returns a new object)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
2
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QHow does count() count occurrences?
AIt uses == to test element equality and counts how many times x appears.
QWhat is returned when nothing is found?
A0, without raising an error.
QDoes count() have range parameters?
ANo. list.count(x) takes only one argument, same as tuple.count(); only index() supports start/end.