title: Python: printing elements from a list till a specific element
body: <p>I have a list of strings with different numbers of words, eg. </p>
  
  <pre><code>abc = ['apple', 'apple ball', 'cat ', 'ball apple', 'dog cat apple',
         'apple ball cat dog', 'cat', 'ball apple']
  </code></pre>
  
  <p>What I have done is that I have counted the number of spaces in each element. What I want to do now is to print all the elements that have less than 3 spaces in them until I reach an element which has 3 or more spaces and not the elements that come after it... for example in the above list I should get the output</p>
  
  <pre><code>apple
  apple ball
  cat
  dog cat apple
  </code></pre>
  
  <p>None of the elements after <code>apple ball cat dog</code> as it has 3 spaces in it. I would also like to point out that I have a list of such lists, so whatever solution you guys can think of, kindly keep in mind that it scales to list of lists :) thank you all...</p>