User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

If02. Given an integer. If it is positive, then add 1; Otherwise subtract from it 2. Output the resulting number.

Solution in Python 3:

A = int(input("Enter the number: "))

if A > 0:
A += 1
else:
A -=2

print(A)