Assume s is a string of lower case characters.

Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print

Number of times bob occurs is: 2
For problems such as these, do not include raw_input statements or define the variable s in any way. Our automating testing will provide a value of s for you - so the code you submit in the following box should assume s is already defined. If you are confused by this instruction, please review L2 Problems 10 and 11 before you begin this problem set.

2 answers

s = "azcbobobegghakl"

search = "bob"

print len([i for i in range(len(s)) if s.startswith(search, i)])
What is the code?
Similar Questions
  1. Assume s is a string of lower case characters.Write a program that prints the longest substring of s in which the letters occur
    1. answers icon 2 answers
  2. Assume s is a string of lower case characters.Write a program that counts up the number of vowels contained in the string s.
    1. answers icon 1 answer
  3. Assume s is a string of lower case characters.Write a program that counts up the number of vowels contained in the string s.
    1. answers icon 2 answers
    1. answers icon 3 answers
more similar questions