In python how can you select the integer that closest to 0?
<p>list [1,2,3,4,5,6]</p>

<p>How would you write a line or lines of code that could sort through the list and find the value closest to 0?</p>

<p>If you don't care about negative numbers use <a href="https://docs.python.org/2/library/functions.html#min" rel="nofollow">min</a>:</p>

<pre><code>&gt;&gt;&gt; arr = [1, 2, 3, 4, 5]
&gt;&gt;&gt; min(arr)
1
</code></pre>

python for-loop