title: Can someone break down this code for non-overlapping occurrences in Python?
body: <p>Suppose count doesn't exist.</p>
  
  <pre><code>string = 'let it be let it'
  substring = 'let it'
  count = 0
  sub_len = len(substring) 
  for i in range(len(string)): 
      if string[i:i+sub_len] == substring:
          count += 1
  print(count)
  &gt;&gt;&gt; 2
  </code></pre>
  
  <p>What's confusing me exactly is this part</p>
  
  <pre><code>for i in range(len(string)):
      if string[i:i+sub_len] == substring:
          count += 1
  </code></pre>
  
  <p>And more specifically </p>
  
  <pre><code>    if string[i:i+sub_len] == substring:
  </code></pre>
  
  <p>I don't get how this adds to the count?</p>
  
  <p>Could someone explain this to me, especially the part in the brackets.</p>