String count
Return the number of substrings in string.
Syntax
The format is:str.count(sub)
or
str.count(sub,start,end)
Parameters
Sub substring to count
Example
str = "The string count method returns the number of sub string occurences. "
print( str.count("string") )
Result:
2
Practice
Stop reading. Start writing Python.
PyChallenge gives you interactive exercises in your browser — no install needed.
Practice Python with interactive exercises