I have a working conditional statement:
if True:
pass
else:
continue
that I would like to turn it into a ternary expression:
pass if True else continue
However, Python does not allow this. Can anyone help?
Thanks!
Point 1: Are your sure your condition is right? Because if True
will always be True
and code will never go to else
block.
Point 2: pass
and continue
are not expressions or values, but a action instead You can not use these is one line. Instead if you use, 3 if x else 4
<-- it will work