Suppose I have the following list: a = [10, 8, 7, 5, 4, 4, 4, 2, 1, 1, 1]
. Suppose I want to find the index of the last entry >=
some threshold e.g. threshold = 4
.
I have written the following code:
a = [10, 8, 7, 5, 4, 4, 4, 2, 1, 1, 1]
threshold = 4
last_index = len(a) - a[::-1].index(threshold) - 1
While this works, it is not very readable - is there a better way of writing this?