For the two lists lst1 and lst2:
lst1 = ['a']
lst2 = [['b'],
['b', 'c'],
['b', 'c', 'd']]
I would like to combine them into a list of several lists with the desired output as follows:
desiredList = [['a', ['b']],
['a', ['b', 'c']],
['a', ['b', 'c', 'd']]]
Here is one of my attempts that is approaching using lst1 + lst2and list.append():
lst3 = []
for elem in lst2:
new1 = lst1
new2 = elem
theNew = new1 + new2
lst3.append(theNew)
print(lst3)
#Output:
#[['a', 'b'],
#['a', 'b', 'c'],
#['a', 'b', 'c', 'd']]
Turning around on this, I thought that another option with theNew = new1.append(new2)would do the trick. But no:
lst3 = []
for elem in lst2:
new1 = lst1
new2 = elem
theNew = new1.append(new2)
lst3.append(theNew)
print(lst3)
[None, None, None]
And you will get the same result with extend.
I think it should be very simple, but I'm at a loss.
Thanks for any suggestions!