I want to write a program which does: If the input number is positive, just print it out; If the input number is negative, print the abs number; if not a number, print "Error"
I don't know how to do the last step.
I want to write a program which does: If the input number is positive, just print it out; If the input number is negative, print the abs number; if not a number, print "Error"
I don't know how to do the last step.
This should work as you said:
num = input( 'need a number:' )
try :
num = int(num)
print( abs(num) )
except ValueError :
print( 'not a number' )