ReferenceString methods
str.count()
How many non-overlapping times a piece of text appears.
Signature
text.count(sub)Parameters
| Name | Means |
|---|---|
sub | what to count |
Returns
An int.
Example
Python
print("one,two,one".count("one"))
print("aaaa".count("aa"))Output
2 2