Smallest unused id python if condition error
<pre><code>def next_id(arr):
    if arr:
        arr.sort()
        if arr[0] != 0:
            return 0
        for i in range(len(arr)):
            if (arr[i]-arr[i+1])&lt;-1:
                return arr[i]+1
            else:
                return arr[len(arr)-1]+1
    else:
        return 0
</code></pre>

<p>I'm trying to find the Smallest unused ID, and for some reason its not entering this if condition: </p>

<pre><code>if (arr[i]-arr[i+1])&lt;-1:
</code></pre>

<p>when I try this </p>

<pre><code>next_id([0,1,2,3,5]
</code></pre>

<p>for test it returns 6 instead of 4.</p>