count() - Returns the number of times a specified value occurs in a string

Returns the number of times a specific character or string.  The count function can take an optional start and end index into the string.

Example

Python
str = 'The quick brown fox jumped over the lazy dog'
occurances = str.count('o')
print(f'The letter "o" occurs {occurances} times')

occurances = str.count('the')
print(f'The word "the" occurs {occurances} times')

# first 10 letters of the string:
occurances = str.count('the', 0, 10)
print(f'The word "the" occurs {occurances} times')

Output

The letter "o" occurs 4 times
The word "the" occurs 1 times
The word "the" occurs 0 times

Notes: The count function is case-sensitive.