Try:
usernum = int(input('Enter a number, Ill determine if its pos, neg, OR Zero.'))
if usernum < 0:
print("Your number is negative.")
if usernum > 0:
print("Your number is positive.")
if usernum == 0:
print("Your number is zero.")
input(...)
creates strings, so you need to make that string an integer by making it go through int(...)
. In addition I'd suggest switching you're ifs into if, elif and else:
usernum = int(input('Enter a number, Ill determine if its pos, neg, OR Zero.'))
if usernum < 0:
print("Your number is negative.")
elif usernum > 0:
print("Your number is positive.")
else:
print("Your number is zero.")
It's not a big deal, but this way you're only executing code you actually need. So, if usernum
is less than 0 then the next clauses aren't evaluated. Finally, you could consider adding user input error correction:
usernum = None
while usernum is None:
try:
usernum = int(input('Enter a number, Ill determine if its pos, neg, OR Zero.'))
except ValueError as ex:
print("You didn't enter an integer. Please try again.")
if usernum < 0:
print("Your number is negative.")
if usernum > 0:
print("Your number is positive.")
if usernum == 0:
print("Your number is zero.")