Skip to content
I need help
Profile icon

Hi everyone. Me again. I need help with a program I'm working on (as usual). So in this code there are two numbers inputted. If exactly one is negative, the program should print YES. If anything else is the input, the program should print NO. So I wrote this:

a = int(input())
b = int(input())

if a < 0:

elif b < 0:

elif a < 0 and b < 0:


The computer seems to be ignoring the command of if both numbers are less than 0. Every time I input two number, the computer outputs YES instead of NO. How do I make it not do that? Help me please??

You are viewing a single comment. View All
Profile icon

Here's how I would do it:

a = int(input()) b = int(input()) if (abs(a) == a or abs(b) == b) and (abs(b) != b or abs(a) != a): print("YES") else: print("NO")