Positive Negative - Simple Python exercise
<p>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.</p>

<p>I finally figured it out.</p>

<pre><code>def pos_neg(a, b, negative):
  if negative:
    return (a &lt; 0 and b &lt; 0)
  else:
    return (a &gt; 0 and b &lt; 0) or (a &lt; 0 and b &gt; 0)
</code></pre>

<p>But... why do I return those two lines instead of True? How do I know to do this in a similar situation?</p>

<p>You are not returning those two lines. You are returning the values that those two lines <em>evaluate to</em>. In your cases, those are boolean expressions that will evaluate to either true or false. That final boolean value is what your function returns.</p>

python