Re: make sublists of a list broken at nth certain list items

2013-07-08 Thread Joshua Landau
On 8 July 2013 22:24, Joshua Landau wrote: > if count == 60: Obviously this should be: if count == length: -- http://mail.python.org/mailman/listinfo/python-list

Re: make sublists of a list broken at nth certain list items

2013-07-08 Thread Joshua Landau
On 8 July 2013 21:52, CM wrote: > I'm looking for a Pythonic way to do the following: > > I have data in the form of a long list of tuples. I would like to break that > list into four sub-lists. The break points would be based on the nth > occasion of a particular tuple. (The list represents

Re: make sublists of a list broken at nth certain list items

2013-07-08 Thread Fábio Santos
You don't want to use index() to figure out the index of the tuples. It is slower, and will not find the item you want if there is more than one of the same. For example, [1, 4, 4, 4].index(4) will always be 1, no matter how many times you loop through it. Instead, use enumerate() to keep track

make sublists of a list broken at nth certain list items

2013-07-08 Thread CM
I'm looking for a Pythonic way to do the following: I have data in the form of a long list of tuples. I would like to break that list into four sub-lists. The break points would be based on the nth occasion of a particular tuple. (The list represents behavioral data trials; the particular tu