i was wondering if anyone could help me figure out how to write a piece of code that would analyze the input a user would put in and count the amount of times a specific word is occurring.
For example, user is prompted to input a string. types in bobobob. We are searching for how many times "bob" appears in this code, and so the answer would be 3.
If this could be done in a for loop/if-else statement without any imports, i would like to see how.
This is what i have, and for some reason its coming up short on most tests
s = raw_input("string: ")
count = len(s.split("bob"))
print count
for example, if you test hoboboobbobbbobobbopbbobbbpbooboboboobbobovob you get 7 instead of 8.
I need to be able to do this without regex or any other imports.