find a number is between which range in a list of list
<p>Need some python help, I have a list: </p>

<pre><code>[[sql1, 1, 10], [sql2, 12, 16]...]
</code></pre>

<p>I want to know if 15 is in the sql2, please let me know in python the easy way. </p>

<p>I have tried in the loop. </p>

<p>First, lest solve for the simplest solution and then look into making something generic out of it.</p>

<pre><code>test_data = [['sql', 1, 10],['sql2', 12, 16, 15]]
print(15 in test_data[1]) # True
</code></pre>

<p>We can even generalize it into a function </p>

<pre><code>def in_data(data_sets, data, check_in):
    for data_set in data_sets:
        if data in data_set:
            if check_in in data_set:
                return True
    return False
</code></pre>

<p>@Robáµ© pointed out a more elegant/compact solution that allows us to write:</p>

<pre><code>def in_data(data_sets, data, check_in):
    return any(check_in in data_set for data_set in data_sets)
</code></pre>

python