How to exit an if clause

前端 未结 13 1749
故里飘歌
故里飘歌 2020-12-04 08:45

What sorts of methods exist for prematurely exiting an if clause?

There are times when I\'m writing code and want to put a break statement

13条回答
  •  既然无缘
    2020-12-04 09:12

    while some_condition:
       ...
       if condition_a:
           # do something
           break
       ...
       if condition_b:
           # do something
           break
       # more code here
       break
    

提交回复
热议问题