How to compare an array value with another explicit value in python
<p>I want to do something like this</p>

<pre><code>while(x&lt;100 for x in someList):
    if someList has a value more than 100
    the loop should end.
</code></pre>

<p>You <em>could</em> use <code>itertools.takewhile</code>:</p>

<pre><code>for x in takewhile(lambda x: x &lt;= 100, someList):
    print(x)
</code></pre>

<p>But I think @sinsuren's <code>break</code> solution is best. I'd only use <code>takewhile</code> when I don't want a loop, for example in <code>sum(takewhile(lambda x: x &lt;= 100, someList))</code>.</p>

python loops compare