I need to count the nunber of times the substring \'bob\' occurs in a string.
\'bob\'
Example problem: Find the number of times \'bob\' occurs in string s such
Here you have an easy function for the task:
def countBob(s): number=0 while s.find('Bob')>0: s=s.replace('Bob','',1) number=number+1 return number
Then, you ask countBob whenever you need it:
countBob('This Bob runs faster than the other Bob dude!')