title: Count number of occurrences of a substring in a string
body: <p>How can I count the number of times a given substring is present within a string in Python?</p>
  
  <p>For example:</p>
  
  <pre><code>&gt;&gt;&gt; 'foo bar foo'.numberOfOccurrences('foo')
  2
  </code></pre>