Check if values in list exceed threshold a certain amount of times and return index of first exceedance
<p>I am searching for a clean and pythonic way of checking if the contents of a list are greater than a given number (first threshold) for a certain number of times (second threshold). If both statements are true, I want to return the index of the first value which exceeds the given threshold.</p>

<p><strong>Example</strong>:</p>

<pre><code># Set first and second threshold
thr1 = 4
thr2 = 5

# Example 1: Both thresholds exceeded, looking for index (3)
list1 = [1, 1, 1, 5, 1, 6, 7, 3, 6, 8]

# Example 2: Only threshold 1 is exceeded, no index return needed
list2 = [1, 1, 6, 1, 1, 1, 2, 1, 1, 1]
</code></pre>

<p>I don't know if it's considered pythonic to abuse the fact that booleans are ints but I like doing like this</p>

<pre><code>def check(l, thr1, thr2):
    c = [n &gt; thr1 for n in l]
    if sum(c) &gt;= thr2:
        return c.index(1)
</code></pre>

python list iterator threshold