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...

Path csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'elif': 0.04; '21,': 0.07; 'false.': 0.07; 'wed,': 0.15; 'ifs': 0.16; 'keyword.': 0.16; 'received:mail-ig0-x22a.google.com': 0.16; 'wrote:': 0.16; '2015': 0.20; 'am,': 0.23; 'code.': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'have,': 0.27; 'branches': 0.29; 'branch': 0.30; 'previous': 0.34; 'skip:d 20': 0.34; 'received:google.com': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'within': 0.64; 'here': 0.66; 'to:name:python': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=ymlEOslJMbqjfs2yZ+KandUWb+ZA3S+x3Id+qtKMjDo=; b=pwSNdqqb25uRIpQ3rL8OUDPo4/Jbl/Tuhm+RoNjiSDamuwl3b0mFj99YtyoKlI6YhW 5qn5qZoSjajXx3F1z/ZoDgwRdTUHH4MAK1CSh+SZJiGCww+vBE7+O82PBBCDXGI/woM7 9Ew55AwasTNak7NOg/JwM8HF608WqCB+n9JgEZcNch++Y6YkwpHSpAw2V6ILsI4fJJrm n4crwr99P4cm0gNDvDFWJw0hJ+jgdJcIzF5Az5RGIhQl1LlAwwSz8UDpKoiUU/Co3RpT 5Hj0v+7W0/fnGS6qVX8VPlxFbgvDwFaMw6jcAMaa1r/ciFn+1kd/quXONMNma0keqkK9 NW0g==
X-Received by 10.50.73.137 with SMTP id l9mr12158126igv.85.1445449215596; Wed, 21 Oct 2015 10:40:15 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com>
References <50a6789a-3965-430b-9a91-b08adcedf7bf@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 21 Oct 2015 11:39:36 -0600
Subject Re: If one IF is satisfied, skip the rest in the nest...
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.75.1445449220.878.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1445449220 news.xs4all.nl 23859 [2001:888:2000:d::a6]:44548
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:97865

Show key headers only | 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