I need to convert a 3d array I have in Python3 into a string with a specific format. My current 3d array is below:
[[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]]
[[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]]
[[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]]
[[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]]
I need this as a string, but also want to replace any instance of 0 and make it into the string '----'. If a value is not 0, then leave it.
I tried using join: ''.join(str(e) for e in myArray) but the format did not come out as I wanted.
I expected my results to look like this:
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
1 ---- ---- ---- ---- ---- ----
But my format turned out like this using the join method:
[[[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]][[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]][[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]][[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]]]