If one IF is satisfied, skip the rest in the nest...

Ian Kelly ian.g.kelly at gmail.com
Wed Oct 21 13:39:36 EDT 2015


On Wed, Oct 21, 2015 at 11:31 AM,  <bigred04bd3 at gmail.com> wrote:
> So here what I have, I have a 3 IF's within the same level.  If one IF is satisfied, I would like to "skip" the other IFs and continue with my code.

I think you're looking for the elif keyword. An elif branch will only
be considered if the previous branches were false.

if a:
    do_something()
elif b:
    do_something_else()
elif c:
    do_something_different()



More information about the Python-list mailing list