generating list of sub lists

Ross Wilson r-w at iinet.net.au
Mon Sep 17 06:52:14 EDT 2007


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
> Francesco
> 

l = [l, l]

Ross



More information about the Python-list mailing list