LoginSignup
2
1

More than 3 years have passed since last update.

三項演算子で break や continue は使えない

Last updated at Posted at 2019-12-03

三項演算子は『式』("expression") に対して使うもの。
break や continue は『式』ではなく『文』("statement") なので下の例のような横着はできませんよ、という話.

ダメな例
for i in range(100):
     break if i > 20 else continue
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1