You cannot use break or continue with the ternary operator

The ternary operator is used for "expression". The story that break and continue are not "expressions" but "statements", so you can't wear them like the example below.

Bad example


for i in range(100):
     break if i > 20 else continue

Recommended Posts

You cannot use break or continue with the ternary operator
Until you use the Kaggle API with Colab
Use "$ in" operator with mongo-go-driver
[Introduction to Python] How to use the Boolean operator (and ・ or ・ not)
Use the preview feature with aws-cli
Technical English> you use the boolean operators [and, or, and not] to ...> Boolean Operations — and, or, not
Note until you use emacs with WSL
[Python] Round up with just the operator
Until you can use opencv with python