title: Finding the number of substrings which sum is equal to m
body: <p>I'm trying some python and I got this:</p>
  
  <p>I have a string S='3,0,4,0,3,1,0,1,0,1,0,0,5,0,4,2' and m=9.
  I want to know how many substrings with with sum equals m there are.</p>
  
  <pre><code>So with S and m above i whould get 7 as a result as:
  '3,0,4,0,3,1,0,1,0,1,0,0,5,0,4,2'
   _'0,4,0,3,1,0,1,0'_____________
   _'0,4,0,3,1,0,1'_______________
   ___'4,0,3,1,0,1,0'_____________
  ____'4,0,3,1,0,1'_______________
  ____________________'0,0,5,0,4'_
  ______________________'0,5,0,4'_
   _______________________'5,0,4'_
  </code></pre>
  
  <p>Now, the code i came up with does something like that</p>
  
  <pre><code>def es1(S,m):
      c = 0
      M = 0
      ls = StringToInt(S)
      for x in ls:
          i= ls.index(x)
          for y in ls[i+1:]:
              M = x + y
              if M == m:
                  c += 1
                  M = 0
                  break
              if M &gt; m:
                  M = 0
                  break
              else:
                  continue
      return c
  
  def StringToInt(ls):
      s = [int(x) for x in ls.split(',')]
      return s
  </code></pre>
  
  <p>Where StringToInt obv gives me a list of int to work with.
  The thing I don't get is where my concept is wrong since es1 returns 3</p>