title: One-liner to conditionally swap a value
body: <p>I've got a variable that can hold one of two values. This simple logic reverses it:</p>
  <pre><code>opt_in_status = some_method_that_returns_an_opt_in_status()
  # switch the opt_in_status
  opt_in_status = &quot;opted_in&quot; if opt_in_status == &quot;unsubscribed&quot; else &quot;unsubscribed&quot;
  </code></pre>
  <p>I don't like the fact that I've hardcoded the magic string <code>unsubscribed</code> twice. I could put that into another variable</p>
  <pre><code>opt_in_status = some_method_that_returns_an_opt_in_status()
  # switch the opt_in_status
  magic_string = &quot;unsubscribed&quot;
  opt_in_status = &quot;opted_in&quot; if opt_in_status == magic_string else magic_string
  </code></pre>
  <p>but is there a more concise one-liner that will do this for me?</p>
  <p>I'm using python 3.9</p>