[Tutor] Multiple lists from single list with nested lists

Sander Sweers sander.sweers at gmail.com
Mon Oct 20 23:33:53 CEST 2008

Hi, I am learning myself python and I need to create 2, or more but
let's use 2 as an example, lists from a list with nested lists.

For example the below,

['Test1', 'Text2', ['1', '2'], 'Text3']

Should result in,

[['Test1', 'Text2', '1', 'Text3'],
['Test1', 'Text2', '2', 'Text3']

I though of using a temp list and looping over the list twice, something like,

somelist = ['Test1', 'Text2', ['1', '2'], 'Text3']
templist = []
for x in range(len(somelist[2])):
    templist.append([somelist[0], somelist[1], somelist[2][x], somelist[3]])
This works but to me looks ugly and would appreciate pointers and/or
someone pointing me to additional reading on this.

Much appreciated,

More information about the Tutor mailing list