PS. Sorry, I wrote:
>>> zip(*[iter(s)]*3) # or simpler: zip(s) :-)
But should be
>>> zip(*[iter(s)]*1) # or simpler: zip(s) :-)
*j
--
http://mail.python.org/mailman/listinfo/python-list
tiago almeida wrote:
Hello all,
I'd like to ask how you'd implement a function /f/ that transforms a
list of elements into a list of lists of elements by grouping
contiguous elements together.
Examples:
a=[1,2,3,4,5]
print( f(a, 2) ) # -> [ [1, 2], [3, 4], [5] ]
print( f(a, 3) ) # -> [ [
08-01-2010 tiago almeida wrote:
Hello all,
I'd like to ask how you'd implement a function *f* that transforms a
list of elements into a list of lists of elements by grouping
contiguous elements together.
Examples:
a=[1,2,3,4,5]
print( f(a, 2) ) # -> [ [1, 2], [3, 4], [5] ]
print( f(a, 3)