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.
This is what I have so far:
def contestTest(): # Neutral point for struggle/tug of war/contest x = 0 while -5 < x < 5: print "Type desired amount of damage." print x choice = raw_input("> ") if choice.isdigit(): y = int(choice) x += y else: print "Invalid input." if -5 >= x: print "x is low. Loss." print x elif 5 <= x: print "x is high. Win." print x else: print "Something went wrong." print x 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.