trying to work through a list in sections
<p>I have a list of lists sorted by the second value of the list (the groups).  I now need to iterate through this to work on each "group" at a time.  the data is <code>[name, group, data1, data2, data3, data4].</code>  I wasn't sure if I need a while or some other sort of loop, or maybe <code>groupby</code> but I've never used that.  any help would be appreciated.</p>

<pre><code>for i in range (int(max_group)):
    x1 = []
    x2 = []
    x3 = []
    x4 = []
    if data[i][1] == i+1:
        x1.append(data[2])
        x2.append(data[3])
        x3.append(data[4])
        x4.append(data[5])
        print x1
        print 'next' # these are just to test where we're at
</code></pre>

<p>all the x's should have all the 3rd-5th column data (after the name and group number) of all the group 1 info. then i can use the group 1 info and move on to group 2.</p>
