Somehow I do not understand the error message I am getting:
IndexError: too many indices for array
I have looked into other questions with that title but none seem to apply to my situation. This is my code.
import numpy as np
def revert_array(array):
max_len = len(array)
ret = np.array(max_len)
for i in range(1, max_len):
ret[i] = array[max_len - i]
return ret
a = np.array([1,2,3,4])
r = revert_array(a)
print(r)
I do give only an integer value as the index. What am I missing?
ret = np.array(max_len)causes error. However, I am not sure about logic of your function, so I can't tell how to fix it.