.count()
Published May 5, 2021Updated Sep 3, 2021
Contribute to Docs
Searches a list for a particular item and returns the number of matching entries found.
Syntax
list.count(value, start, end)
The .count()
method has three parameters:
value
: The string to search for. (Required)start
: The index to start the search. Default is index 0.end
: The position to end the search. Default is end of the string.
Example 1
To count the number of 'pen'
within the backpack
list:
Example 2
To count the number of 'pen'
within the backpack
list from index 0 to index 5:
All contributors
- Anonymous contributorAnonymous contributor3077 contributions
- christian.dinh
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.