I have a matrix \'A\' whose values are shown below. After creating a matrix \'B\' of ones using numpy.ones and assigning the values from \'A\' to \'B\' by indexing \'i\' rows an
Python starts counting at 0, so your code should work find if you replace np.arange(1,9) with np.arange(9)
np.arange(1,9)
np.arange(9)
In [11]: np.arange(1,9) Out[11]: array([1, 2, 3, 4, 5, 6, 7, 8]) In [12]: np.arange(9) Out[12]: array([0, 1, 2, 3, 4, 5, 6, 7, 8])