Re: generating list of sub lists

2007-09-17 Thread Steven D'Aprano
On Mon, 17 Sep 2007 20:52:14 +1000, Ross Wilson wrote: > cesco wrote: >> Hi, >> >> is there a one-liner to accomplish the following task? >>>From the list >> l = ['string1', 'string2', 'string3'] generate the list of lists >> l = [['string1'], ['string1', 'string2'], ['string1', 'string2', >> 'st

Re: generating list of sub lists

2007-09-17 Thread Ross Wilson
cesco wrote: > Hi, > > is there a one-liner to accomplish the following task? >>From the list > l = ['string1', 'string2', 'string3'] > generate the list of lists > l = [['string1'], ['string1', 'string2'], ['string1', 'string2', > 'string3']] > > Any help would be appreciated. > > Thanks > Fran

Re: generating list of sub lists

2007-09-16 Thread Steve Holden
Rustom Mody wrote: > On 9/16/07, cesco <[EMAIL PROTECTED]> wrote: >> Hi, >> >> is there a one-liner to accomplish the following task? >> >From the list >> l = ['string1', 'string2', 'string3'] >> generate the list of lists >> l = [['string1'], ['string1', 'string2'], ['string1', 'string2', >> 'stri

Re: generating list of sub lists

2007-09-16 Thread Rustom Mody
On 9/16/07, cesco <[EMAIL PROTECTED]> wrote: > Hi, > > is there a one-liner to accomplish the following task? > >From the list > l = ['string1', 'string2', 'string3'] > generate the list of lists > l = [['string1'], ['string1', 'string2'], ['string1', 'string2', > 'string3']] > > Any help would be

Re: generating list of sub lists

2007-09-16 Thread Jesús Carrete Montaña
cesco wrote: > l = ['string1', 'string2', 'string3'] l2=[l[:i+1] for i in range(len(l))] -- http://mail.python.org/mailman/listinfo/python-list

generating list of sub lists

2007-09-16 Thread cesco
Hi, is there a one-liner to accomplish the following task? >From the list l = ['string1', 'string2', 'string3'] generate the list of lists l = [['string1'], ['string1', 'string2'], ['string1', 'string2', 'string3']] Any help would be appreciated. Thanks Francesco -- http://mail.python.org/mail