title: Improving Python function to count occurrences of a substring
body: <p>I'm a relatively inexperienced programmer (but pretty experienced in general) and am looking to improve my Python skills (my language of choice).  I've written some useful tools with Python but really want to take my programming/scripting to the next level.  I understand the logic but lack familiarity with much of the library.  I've been practicing simple programming tasks in Python, and my most recent practice example is a function that takes a string and a substring and outputs the number of occurrences of the substring within the string:</p>
  
  <pre><code>from re import match
  
  def MyFunc(string, substring):
      n = len(substring)
      substring_count = 0
      x = 0
      for char in string:
          if match(substring, string[x:x+n]):
              substring_count = substring_count + 1
          x = x + 1
      return substring_count
  </code></pre>
  
  <p>Is this an efficient way of doing this?  Is my code particularly Pythonish? I also tried another solution without using regex but wasn't nearly as successful.</p>