0

I have a list like this:

a=[[[[5]]]]

and I would like to reduce the nests and get result as below:

a=[5]

I think it's not a big deal, but I don't know how to do it and find no way to this.... Thank you very much

Jen
  • 339
  • 1
  • 2
  • 12
  • Write this `a=a[0][0][0]` – Laure Nov 23 '17 at 09:37
  • If you have a single element list, you can simplify the recursion step... but that's for you to figure out. – cs95 Nov 23 '17 at 09:38
  • 2
    Maybe you could avoid creating the nested list in the first place? – Chris_Rands Nov 23 '17 at 09:38
  • @Chris_Rands actually this is not I created but read from other data. and the real data is not so simple but like this: [[ [[1,2,3,4,5,],[2,3,4,5,6] ] ,[1,2,3,4,5], [1,2,3,4,5] ]] there are too many useless [[ ]] – Jen Nov 24 '17 at 02:10
  • @laure I think this a good idea, but something bad is actually I don't know how many nest in my variable read from the data – Jen Nov 24 '17 at 02:13

0 Answers0