I need to count the nunber of times the substring \'bob\'
occurs in a string.
Example problem: Find the number of times \'bob\' occurs in string s such
Here is a solution that returns number of overlapping sub-strings without using Regex: (Note: the 'while' loop here is written presuming you are looking for a 3-character sub-string i.e. 'bob')
bobs = 0
start = 0
end = 3
while end <= len(s) + 1 and start < len(s)-2 :
if s.count('bob', start,end) == 1:
bobs += 1
start += 1
end += 1
print(bobs)