On 01/13/13 07:48, Boris FELD wrote:
2013/1/13 Tim Chase <python.l...@tim.thechases.com>:
SIZE = 3
for i in range(len(list1)//SICE):
...     print list1[i*SIZE:i*SIZE+SIZE]

A little shorter and simpler version:
x = x[1:]
for i in range(0,len(x),SIZE):
...      print x[i: i+SIZE]

Doh, I always forget that range() takes an optional stride. Or rather, I use it so infrequently that I reach for other alternatives before it occurs to me :)

-tkc



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to