title: create more lists from one big list
body: <p>I have the following list which was created from a text file  that I already have.</p>
  <p>In the end I have a list that contains all the values that I need from the text, and now I am trying to have a more than one small lists from the list array where every small list start with switch and end where the value is empty.</p>
  <pre><code>with open(&quot;read.txt&quot;) as f:
      for line in f:
          if line.startswith('switch '):
              array.append(line)
              for line in f:  # Continue iterating f for additional lines to keep
                  if not line.rstrip():
                      break  # We hit an empty line, return to looking for switch
                  array.append(line)
  </code></pre>