On Dec 28, 5:28 pm, Vlastimil Brom <vlastimil.b...@gmail.com> wrote: > 2009/12/27 joy99 <subhakolkata1...@gmail.com>: > > > Dear Group, > > Answers were good. But I am looking for a smarter solution like: > > > for i[:2] in list: > > .... > > > etc. or by doing some looping over loop. > > Do not worry I'll work out the answer. > > > Wishing you a happy day ahead, > > Regards, > > Subhabrata. > > -- > >http://mail.python.org/mailman/listinfo/python-list > > Hi, > maybe just something like: > > >>> input_list = range(10) > >>> n = 3 > >>> [input_list[i:i+n] for i in range(0, len(input_list), n)] > > [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]] > > ? > (possibly using xrange and generator expression instead of the list > comprehension) > > vbr
vbr, Just Brilliant. I manipulated it bit but I got the key, but thanks to all for giving me lots of solutions and lots of insights over Python. Everytime I visit this room I learn so much. Thank you all. Wishing a Great Day ahead, Best Regards, Subhabrata. -- http://mail.python.org/mailman/listinfo/python-list