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>You're going to have to give a few more details about your desired implementation, but this was too fun not to answer. </p>

<p>My answer assumes:</p>

<ol>
<li>You want a list of the beginning strings (<code>index == 0</code>) of the sublists whose:</li>
<li>2nd and 3rd elements contain <code>15</code> in the range of a (inclusive) and b (exclusive)</li>
</ol>

<p>This is in Python 3.</p>

<pre>
>>> x = [['sql1', 1, 10], ['sql2', 12, 16]]
>>> [a for a, *b in x if 15 in range(*b)]
['sql2']
</pre>

<p>This also works with multiple matches:</p>

<pre><code>&gt;&gt;&gt; x = [['sql1', 1, 10], ['sql2', 12, 16], ['sql3', 15, 17]]
&gt;&gt;&gt; [a for a, *b in x if 15 in range(*b)]
['sql2', 'sql3']
</code></pre>

<p>If you want to accept <code>'sql2'</code> and <code>15</code> as input and return a boolean:</p>

<pre><code>&gt;&gt;&gt; x = [['sql1', 1, 10], ['sql2', 12, 16]]
&gt;&gt;&gt; check = 'sql2'
&gt;&gt;&gt; n = 15
&gt;&gt;&gt; any(a == check and n in range(*b) for a, *b in x)
True
</code></pre>

python