title: Python groupby to split list by delimiter
body: <p>I am pretty new to Python (3.6) and struggling to understand itertools groupby.
  I've got the following list containing integers:</p>
  
  <pre><code>    list1 = [1, 2, 0, 2, 3, 0, 4, 5, 0]
  </code></pre>
  
  <p>But the list could also be much longer and the '0' doesn't have to appear after every pair of numbers. It can also be after 3, 4 or more numbers. My goal is to split this list into sublists where the '0' is used as a delimiter and doesn't appear in any of these sublists.</p>
  
  <pre><code>    list2 = [[1, 2], [2, 3], [4, 5]]
  </code></pre>
  
  <p>A similar problem has been solved here already:
  <a href="https://stackoverflow.com/questions/15357830/python-spliting-a-list-based-on-a-delimiter-word">Python spliting a list based on a delimiter word</a>
  Answer 2 seemed to help me a lot but unfortunately it only gave me a TypeError.</p>
  
  <pre><code>    import itertools as it
  
      list1 = [1, 2, 0, 2, 3, 0, 4, 5, 0]
  
      list2 = [list(group) for key, group in it.groupby(list1, lambda x: x == 0) if not key]
  
      print(list2)
  </code></pre>
  
  <blockquote>
    <p>File "H:/Python/work/ps0001/example.py", line 13, in 
        list2 = [list(group) for key, group in it.groupby(list, lambda x: x == '0') if not key]</p>
    
    <p>TypeError: 'list' object is not callable</p>
  </blockquote>
  
  <p>I would appreciate any help and be very happy to finally understand groupby.</p>