I get a nested list as input.
Simplified version is as under.
myList=[[[1,2,3],[4,5,6]],[[2,3,4],[3,4,5]],[[4,6,7],[5,7,9]]]
I wish to unpack it into a simple list of lists.
I can do like this--
simpleList=[]
for i in myList:
for j in i:
simpleList.append(j)
As desired, the simpleList is
[[1, 2, 3], [4, 5, 6], [2, 3, 4], [3, 4, 5], [4, 6, 7], [5, 7, 9]]
My question:-
What I did was, maybe, a beginner's coding approach.
Is there a more professional, efficient (and pythonic) approach to unpack this nested list?
Thanks.
EDIT:-
My method doesn't work for deeply nested lists.
e.g. [[[1,2,3],[4,5,6]],[[2,3,4],[3,4,5]],[[4,6,7],[5,7,9]],[[1,2,3],[4,5,6]],[[2,3,4],[3,4,5]],[[4,6,7],[5,7,9],[[1,2,3],[4,5,6]],[[2,3,4],[3,4,5]],[[4,6,7],[5,7,9]]]]
pl. refer to the comments to answers.