Python if and elif not working, giving error
<p>I'm new in Python and doing an online tutorial. I have an assignment that I can not accomplish. My problem is that when I run this code, the <code>minimum</code> variable stays the same to <code>None</code> and does not record the new value input.</p>

<pre><code>maximum = None
minimum = None
while True:
    try:
        num2 = raw_input('Type here ')
        if num2 == 'done':break
        else:
            num = int(num2)
            if num &lt;= minimum:
                minimum = num
                print minimum
            elif num &gt;= maximum:
                maximum = num
                print maximum


    except:
        print 'Invalid Entry'


print 'Maximum is %d' % maximum
print 'Minimum is %d' % minimum
</code></pre>

<p>You are comparing <code>None</code> and <code>int</code>, Python does not know how to do that.
Instead, you should do:</p>

<pre><code>maximum = float('-inf')
minimum = float('inf')
</code></pre>

<p>Any <code>int</code> would be greater than <code>-infinity</code> and lower than <code>infinity</code>, so things will work fine. Same thing can not be said about zeroes, so don't use those.</p>

<p>Also, look up <code>min</code> and <code>max</code> <a href="https://docs.python.org/2/library/functions.html" rel="nofollow">builtins</a>.</p>

python python-2.7 if-statement