0

I have a 'n' dimensional array which I want to convert to 1'd

[[1', '2], '3', [4', '5', '6']]

to

[1', '2, '3', 4', '5' , '6']

I do not want to use numpy flatten function but want to achieve it through core python and efficient way. Apart from iterating them is there any inbuilt function to do it for me?

bharatk
  • 4,202
  • 5
  • 16
  • 30
syv
  • 3,528
  • 7
  • 35
  • 50
  • Possible duplicate of: https://stackoverflow.com/questions/952914/how-to-make-a-flat-list-out-of-list-of-lists – Newskooler Sep 13 '19 at 12:29
  • The problem Im facing is example if I have [[1', '2], '300', ['4', '5', '6']]., it becomes ['1', '2', '3', '0', '0', '4', '5', '6'] but I want [1', '2, '300', '4', '5', '6'] .. thats where the issue is – syv Sep 13 '19 at 12:36
  • Try the solution from the question your question was marked a duplicate as, then: https://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists – L3viathan Sep 13 '19 at 13:27

0 Answers0