I understand nested list comprehension, but searched to see if it were possible to use nested list comprehension to separate the list in individual items on something like this: list1 = [ [1,2,3], [10,11,12], [100,111,112], [1, 10, 11, [1000101]]]
I have not found anything online about it.
This was my idea:
def foo(x):
for a in x:
for b in a:
if type(b) != list:
unpacked = [b for a in x for b in a]
if type(b) == list:
unpacked.append(*b)
return unpacked
However, the output is this: [1, 2, 3, 10, 11, 12, 100, 111, 112, 1, 10, 11, [1000101], 1000101]