what could be a nice one-liner to get the highest index in a python array whose value is defined (i.e. not None):
f( [None, 1, 5, None, 3, None, None] )
Loop over the reversed of the list and return the first valid item's index:
In : next((len(l) - i for i, j in enumerate(l[::-1], 1) if j is not None), 'NOT FOUND') Out: 4
Note that since you are looping over the reversed array the correct index would be
len(l) - i (if we consider the first index as 1).