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) ) # -> [ [1, 2, 3], [4, 5] ] print( f(a, 1) ) # -> [ [1], [2], [3], [4], [5] ] I have done a small function that does this using a while loop but what I'm looking for is a more *pythonic* way to do this. Maybe some function in some standard Module does this and I don't know? Ps: I don't post the function here because I don't have it with me. Thanks a lot in advance! Tiago Almeida tiago.b.alme...@gmail.com
-- http://mail.python.org/mailman/listinfo/python-list