Possible Duplicate:
What is the most “pythonic” way to iterate over a list in chunks?
Here is an example of my question:
l = [1,2,3,4,5,6,7,8,9]
Then if groupsize = 3, I want:
l1 = [(1,2,3),(4,5,6),(7,8,9)]
if groupsize = 4, then,
l1 = [(1,2,3,4),(5,6,7,8),(9,)]
Thanks.