Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97865

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

References <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2015-10-21 11:39 -0600
Subject Re: If one IF is satisfied, skip the rest in the nest...
Newsgroups comp.lang.python
Message-ID <mailman.75.1445449220.878.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Oct 21, 2015 at 11:31 AM,  <bigred04bd3@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()

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

If one IF is satisfied, skip the rest in the nest... bigred04bd3@gmail.com - 2015-10-21 10:31 -0700
  Re: If one IF is satisfied, skip the rest in the nest... Ian Kelly <ian.g.kelly@gmail.com> - 2015-10-21 11:39 -0600
  Re: If one IF is satisfied, skip the rest in the nest... John Gordon <gordon@panix.com> - 2015-10-21 17:46 +0000
  Re: If one IF is satisfied, skip the rest in the nest... bigred04bd3@gmail.com - 2015-10-21 10:55 -0700
  Re: If one IF is satisfied, skip the rest in the nest... Denis McMahon <denismfmcmahon@gmail.com> - 2015-10-21 19:48 +0000
    Re: If one IF is satisfied, skip the rest in the nest... Grant Edwards <invalid@invalid.invalid> - 2015-10-21 20:07 +0000
      Re: If one IF is satisfied, skip the rest in the nest... Denis McMahon <denismfmcmahon@gmail.com> - 2015-10-22 02:08 +0000

csiph-web