I learnt today that you could use a running index to fetch the next occurrence of your substring:
string = 'bobobobobobobob' # long string or variable here
count = 0
start = 0
while True:
index = string.find('bob', start)
if index >= 0:
count += 1
start += 1
else:
break
print(count)
Returns 7