I have a list like this
myList = [0.0 , 0.0, 0.0, 2.0, 2.0]
I would like to find the location of the first number in the list that is not e
Using next with enumerate is excellent when the array is large. For smaller arrays, I would use argmax from numpy so that you won't need a loop:
next
enumerate
argmax
numpy
import numpy as np myList = [0.0, 0.0, 0.0, 2.0, 2.0] myArray = np.array(myList) np.argmax(myArray > 0) 3