Given 2 int values, return True if one is negative and one is positive. Except if the parameter “negative” is True, then return True only if both are negative.

def pos_neg(a, b, negative):
if negative:
return (a < 0 and b < 0)
else:
return ((a < 0 and b > 0) or (a > 0 and b < 0))_

yea, i understood that a bit late. Can you tell me what do you understand? It is much easier to fill in the blanks, i have currently no idea of your level of understanding

in short, first you check if negative is true:

if negative:

if so, you have to check if both a and b are smaller then zero.

if negative is false, you need to check if one number is negative and the other is positive.

well, in the end it matters if the condition evaluates to True. For example this would be True:

if True:

and this would be false:

if False:

you don’t always have to compare. You can simply (in particular if you have boolean values) just let if decide if it is true or false.

same goes for the return, python will evaluate to use the conditions to True or False. Which you can then simply return. It is a clever trick, and running it in a python IDLE will show it nicely:

return a < 0 and b < 0 if negative else a < 0 and b > 0 or a > 0 and b < 0

it becomes a bit unreadable. also, this is python, you don’t need that many parentheses. and is evaluate before or and return doesn’t require parentheses. So you can remove all the parentheses