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
String capitalize
String find