How to exit an if clause

前端 未结 13 1766
故里飘歌
故里飘歌 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:11

    may be this?

    if some_condition and condition_a:
           # do something
    elif some_condition and condition_b:
               # do something
               # and then exit the outer if block
    elif some_condition and not condition_b:
               # more code here
    else:
         #blah
    if
    

提交回复
热议问题