Home>

There is an array:

[0 1 10 11 100 101 110 111 1000 1001 1010 1011
  1100 1101 1110 1111 10000 10001 10010 10011 10100 10101 10110 10111
 11000 11001 11010 11011 11100 11101]

How to replace these spaces with many arrays, like this:

[[0], [1], [10], [11], [100], [101], [110], [111], ...]
  • Answer # 1

    Try this:

    arr= [0 1 10 11 100 101 110 111 1000 1001 1010 1011
      1100 1101 1110 1111 10000 10001 10010 10011 10100 10101 10110 10111
     11000 11001 11010 11011 11100 11101] # Commas are too lazy to put down, sorry. Imagine they are there.
    arr.shape= (len (arr), 1)
    

    If that doesn't work, try swapping len (arr) and 1 .

    Better yet:

    arr= [0 1 10 11 100 101 110 111 1000 1001 1010 1011
      1100 1101 1110 1111 10000 10001 10010 10011 10100 10101 10110 10111
     11000 11001 11010 11011 11100 11101] # Commas are too lazy to put down, sorry. Imagine they are there.
    arr.reshape ((len (arr), 1))
    

    If it doesn't work out, the advice is the same as above.