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


Groups > comp.lang.python > #37152

Re: Else statement executing when it shouldnt

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <porto143@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'received:209.85.223': 0.03; '21,': 0.07; 'executed': 0.07; 'cc:addr:googlegroups.com': 0.09; 'cc:addr:python-list': 0.10; 'examples:': 0.16; 'subject:when': 0.16; 'mon,': 0.16; 'wrote:': 0.17; '&lt;': 0.17; 'jan': 0.18; 'sender:addr:gmail.com': 0.18; 'email addr:gmail.com&gt;': 0.20; '&gt;': 0.23; 'branch': 0.23; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'url:mailman': 0.29; 'url:python': 0.32; 'url:listinfo': 0.32; 'received:google.com': 0.34; 'received:209.85': 0.35; 'explain': 0.36; 'url:org': 0.36; 'cc:no real name:2**1': 0.36; 'execute': 0.37; 'detail': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'url:mail': 0.40; 'skip:\xc2 10': 0.62; 'more': 0.63; '20,': 0.65; '8bit%:38': 0.65; '2013': 0.84; 'rene': 0.84; 'eli': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=D74+5JnQ82k8PC9pEF3qlmzCO0OcKUQS0d+BSDYoOQY=; b=J2/CzpsJoqRZ6JWFES4LlE8echx8LewMlBn9FfIeQhovYXAdHLnaW4r1OKnF8KYFfk fskr2i2mbXJjoq/sykll0qyRxy/aeFQ9UZzNI+cZS76TQ4kuNopLzCm4Dq8x8few5MEU JZemPlUjn5szbMvc99SPH1IQdQb3rqaID7XIwoLcYmjhCde/QIpXqGL2kAqOVowzWP34 a+8SbWgNaC8lPj++FWg6/ODTDZoBCs0lHnySGWhhw7YKQyRNR0zf9TrlbtD+VkHP0IMd fvIT8ud7VEw9OewaW19DgrLEcszyrjAq7N3qHaiyDDgvSWEtAcBXeNjJgfx4VPFhPG/E JzZA==
MIME-Version 1.0
X-Received by 10.50.183.227 with SMTP id ep3mr7781625igc.107.1358744828604; Sun, 20 Jan 2013 21:07:08 -0800 (PST)
Sender porto143@gmail.com
In-Reply-To <c0d99c75-c82c-4456-a802-55f9bfd43240@googlegroups.com>
References <2cc6791f-ba56-406c-a5b0-b23023caf4bb@googlegroups.com> <mailman.719.1358744056.2939.python-list@python.org> <c0d99c75-c82c-4456-a802-55f9bfd43240@googlegroups.com>
Date Mon, 21 Jan 2013 06:07:08 +0100
X-Google-Sender-Auth jEkW0VKWqeTCg5FpRAJh8hEBG6k
Subject Re: Else statement executing when it shouldnt
From René Klačan <rene.klacan@gmail.com>
To eli m <techgeek201@gmail.com>
Content-Type multipart/alternative; boundary=14dae9340d91d96fe904d3c56e2a
Cc python-list@python.org, comp.lang.python@googlegroups.com
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.725.1358744831.2939.python-list@python.org> (permalink)
Lines 114
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358744831 news.xs4all.nl 6886 [2001:888:2000:d::a6]:46675
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37152

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Examples:

# else branch will be executed
i = 0
while i < 5:
    i += 1
else:
    print('loop is over')


# else branch will be executed
i = 0
while i < 5:
    i += 1
    if i == 7:
        print('i == 7')
        break
else:
    print('loop is over')


# else branch wont be executed
i = 0
while i < 5:
    i += 1
    if i == 3:
        print('i == 3')
        break
else:
    print('loop is over')

On Mon, Jan 21, 2013 at 5:57 AM, eli m <techgeek201@gmail.com> wrote:

> On Sunday, January 20, 2013 8:54:13 PM UTC-8, René Klačan wrote:
> > You have to break while loop not to execute else branch
> >
> >
> > Rene
> >
> >
> >
> Can you explain in more detail please.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

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


Thread

Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:40 -0800
  Re: Else statement executing when it shouldnt Roy Smith <roy@panix.com> - 2013-01-20 23:47 -0500
  Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-21 15:52 +1100
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:55 -0800
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:55 -0800
  Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:54 -0800
    Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-20 22:00 -0800
      Re: Else statement executing when it shouldnt Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-21 08:04 +0000
  Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-21 05:54 +0100
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:57 -0800
      Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-21 06:06 +0100
      Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-21 06:07 +0100
        Re: Else statement executing when it shouldnt Thomas Boell <tboell@domain.invalid> - 2013-01-22 16:39 +0100
          Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-23 02:42 +1100
            Re: Else statement executing when it shouldnt Thomas Boell <tboell@domain.invalid> - 2013-01-22 16:48 +0100
              Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-23 03:07 +1100
              Re: Else statement executing when it shouldnt Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-22 23:22 +0000
                Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-23 01:34 +0100
                Re: Else statement executing when it shouldnt Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-22 22:11 -0500
              Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-22 17:28 -0800
                Re: Else statement executing when it shouldnt Thomas Boell <tboell@domain.invalid> - 2013-01-23 12:22 +0100
                Re: Else statement executing when it shouldnt Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-01-23 15:35 +0200
                Re: Else statement executing when it shouldnt Jerry Hill <malaclypse2@gmail.com> - 2013-01-23 09:53 -0500
                Re: Else statement executing when it shouldnt Frank Millman <frank@chagford.com> - 2013-01-25 10:15 +0200
          Re: Else statement executing when it shouldnt Duncan Booth <duncan.booth@invalid.invalid> - 2013-01-22 15:48 +0000
            Re: Else statement executing when it shouldnt Duncan Booth <duncan.booth@invalid.invalid> - 2013-01-22 15:52 +0000
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:57 -0800
  Re: Else statement executing when it shouldnt Mitya Sirenef <msirenef@lightbird.net> - 2013-01-20 23:57 -0500
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:59 -0800
      Re: Else statement executing when it shouldnt Mitya Sirenef <msirenef@lightbird.net> - 2013-01-21 01:09 -0500
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:59 -0800
      Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-20 21:46 -0800
  Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-20 21:56 -0800
    Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-21 07:37 -0800
      Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-22 05:44 +1100

csiph-web