Don't use try
and except
, they are for error handling. Instead try:
def algop(num):
if num == 0:
return "The number is neither positive nor negative"
sally = num + 1
if num - sally == -1:
return int(num), str("is positive")
else:
return int(num), str("Is negative")
print(algop(10))
Also you don't need to do that code for checking positive or negative, just do <
and >
, also you could just do f-strings:
def algop(num):
if num == 0:
return "The number is neither positive nor negative"
if num > 0:
return f'{num} is positive'
else:
return f'{num} is negative'
print(algop(10))
Both codes output:
10 is positive
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…