s = "azcbobobegghakl"
search = "bob"
print len([i for i in range(len(s)) if s.startswith(search, i)])
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
What is the code?