Using conditional expressions and incrementing/decrementing a variable
<p>How do I to put the if statement into a conditional expression and how do I increment/ decrement a variable?</p>

<pre><code>num_users = 8
update_direction = 3

num_users = 
if update_direction ==3:
   num_users= num_users + 1
else:
   num_users= num_users - 1

print('New value is:', num_users)
</code></pre>

<p>The correct statement would be:</p>

<pre><code>num_users = num_users + 1 if update_direction == 3 else num_users - 1
</code></pre>

<p>For reference, see <a href="https://docs.python.org/2/reference/expressions.html#conditional-expressions" rel="nofollow">Conditional Expressions</a>.</p>

python