Write a program that prints the number of times the string contains a substring
<pre><code>s = "bobobobobobsdfsdfbob"
count = 0 
for x in s : 
    if x == "bob" : 
       count += 1
print count
</code></pre>

<p>i want to count how many bobs in string s, the result if this gives me 17 
what's wrong with my code i'm newbie python.</p>

<p>you can use string.count</p>

<p>for example:</p>

<pre><code>s = "bobobobobobsdfsdfbob"
count = s.count("bob")
print(count)
</code></pre>

python python-2.7 python-3.x