fork(4) download
  1. s = 'gfdhbobobyui'
  2. bob = 0
  3. for x in range(len(s) -3):
  4. if s[x:x+3] == 'bob': # From x to three 3 characters ahead.
  5. bob += 1
  6. print('Number of times bob occurs is: ' + str(bob))
Success #stdin #stdout 0.01s 7852KB
stdin
Standard input is empty
stdout
Number of times bob occurs is: 2