0

If I have some list which has sublists, and that sublists also have sublists etc, how to flatten everything at one level? Let's assume that max sublist level is <= 10. I know how to do that for 2-3 levels by loops, but there must be some algorithm to achieve this without <= 10 for loops. All elements are different, but it does not matter.

L=[[a,b],[[c,d,[e,f]],[g,[[h],i],j,[k,l,m]]...] # start list
newL = [a,b,c,d,e,f,g,h,i,j,k,l,m] # resulted list
Anand S Kumar
  • 88,551
  • 18
  • 188
  • 176
Rade Tomovic
  • 298
  • 2
  • 14
  • This answer is here: [http://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python](http://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python) – chaggy Jul 30 '15 at 15:23
  • @RadeTomovic Do you want the deepest sub-list level? – Anand S Kumar Jul 30 '15 at 15:30
  • 1
    @AnandSKumar and I missed that the title of the question mentioned a count but it was never in the body of the question, so it was a duplicate after all. – Mark Ransom Jul 30 '15 at 15:30

0 Answers0