>>> import numpy as np >>> np.max(np.nonzero([-2, -2, 0, 0, 0, 0, 0])) 1 # at index 1 >>> np.max(np.nonzero([-2, 20, -1, 0, 3, 0, 0])) 4 # at index 4