Nov-23-2017, 12:06 PM
m = np.chararray((10, 10)) m[:] = "*" m(5, 4), m(5, 6) = "O", "O"So I have the following character array:
Output:m = [['*' '*' '*' '*' '*' '*' '*' '*' '*' '*']
['*' '*' '*' '*' '*' '*' '*' '*' '*' '*']
['*' '*' '*' '*' '*' '*' '*' '*' '*' '*']
['*' '*' '*' '*' '*' '*' '*' '*' '*' '*']
['*' '*' '*' '*' '*' '*' '*' '*' '*' '*']
['*' '*' '*' '*' 'O' '*' 'O' '*' '*' '*']
['*' '*' '*' '*' '*' '*' '*' '*' '*' '*']
['*' '*' '*' '*' '*' '*' '*' '*' '*' '*']
['*' '*' '*' '*' '*' '*' '*' '*' '*' '*']
['*' '*' '*' '*' '*' '*' '*' '*' '*' '*']]
I want to insert a row at the beginning and the end. Specifically, I want the following character array:Output:m = [['X' 'X' 'X' 'X' 'X' 'X' 'X' 'X' 'X' 'X' 'X' 'X']
['X' '*' '*' '*' '*' '*' '*' '*' '*' '*' '*' 'X']
['X' '*' '*' '*' '*' '*' '*' '*' '*' '*' '*' 'X']
['X' '*' '*' '*' '*' '*' '*' '*' '*' '*' '*' 'X']
['X' '*' '*' '*' '*' '*' '*' '*' '*' '*' '*' 'X']
['X' '*' '*' '*' '*' '*' '*' '*' '*' '*' '*' 'X']
['X' '*' '*' '*' '*' 'O' '*' 'O' '*' '*' '*' 'X']
['X' '*' '*' '*' '*' '*' '*' '*' '*' '*' '*' 'X']
['X' '*' '*' '*' '*' '*' '*' '*' '*' '*' '*' 'X']
['X' '*' '*' '*' '*' '*' '*' '*' '*' '*' '*' 'X']
['X' '*' '*' '*' '*' '*' '*' '*' '*' '*' '*' 'X']
['X' 'X' 'X' 'X' 'X' 'X' 'X' 'X' 'X' 'X' 'X' 'X']]
Adding the values of 'X' to the end of each row is easily done with an append. However, I cannot find any way of inserting an entire row to the beginning and the end of the array. Inserting an element to the beginning of each row is also proving difficult. Any ideas?