Ternary using pass keyword python
<p>I have a working conditional statement:</p>

<pre><code>if True:
    pass
else:
    continue
</code></pre>

<p>that I would like to turn it into a ternary expression:</p>

<pre><code>pass if True else continue
</code></pre>

<p>However, Python does not allow this. Can anyone help? </p>

<p>Thanks!</p>

<p><code>pass</code> and <code>continue</code> are a statements, and cannot be used within ternary operator, since the operator expects expressions, not statements. Statements don't evaluate to values in Python.</p>

<p>Nevertheless, you can still shorten the condition you brought like this:</p>

<pre><code>if False: continue
</code></pre>

python conditional ternary