How do I check if a string is a negative number before passing it through int()?
<p>I'm trying to write something that checks if a string is a number or a negative. If it's a number (positive or negative) it will passed through int(). Unfortunately isdigit() won't recognize it as a number when "-" is included.</p>

<p>This is what I have so far:</p>

<pre><code>def contestTest():
# Neutral point for struggle/tug of war/contest
x = 0

while -5 &lt; x &lt; 5:
    print "Type desired amount of damage."
    print x
    choice = raw_input("&gt; ")

    if choice.isdigit():
        y = int(choice)
        x += y
    else:
        print "Invalid input."

if -5 &gt;= x:
    print "x is low. Loss."
    print x
elif 5 &lt;= x:
    print "x is high. Win."
    print x
else:
    print "Something went wrong."
    print x
</code></pre>

<p>The only solution I can think of is some separate, convoluted series of statements that I might squirrel away in a separate function to make it look nicer. I'd be grateful for any help!</p>