You cannot; continue
is a statement and the conditional expression is an expression, and you cannot use a statement inside an expression. After all, the continue
statement doesn't produce a value for the conditional expression to return.
Use an if
statement instead:
if i == 5:
x = i
else:
continue
or better:
if i != 5:
continue
x = i