title: Count spaces in text (treat consecutive spaces as one)
body: <p>How would you count the number of spaces or new line charaters in a text in such a way that consecutive spaces are counted only as one?
  For example, this is very close to what I want:</p>
  
  <pre><code>string = "This is an  example text.\n   But would be good if it worked."
  counter = 0
  for i in string:
      if i == ' ' or i == '\n':
          counter += 1
  print(counter)
  </code></pre>
  
  <p>However, instead of returning with <code>15</code>, the result should be only <code>11</code>.</p>