Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 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; '<': 0.17; 'jan': 0.18; 'sender:addr:gmail.com': 0.18; 'email addr:gmail.com>': 0.20; '>': 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; 'more': 0.63; '20,': 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=aWjOBoHapY/xrHhxlQXi+4UtDzaXi7x9Y6zFX9E82SM=; b=0bSuO8YLGzKa8KKWrxrDZ57YmQO7+Y4zq+Qp5eYEwaJiAy7lQZxocoi8E4tIHPdTTj Xt349z+x0w0GbZFJWY8B4HIiY/pSK/VIvLvZk/fhHaL/7UR4iKUXqurRF3k2CIqyKSQ6 /SQ1ypn0urwfVXK0IR00izacgqEGwolXwKexKrZw0xJSRXgyeJdXlRD3xVzoJ4wM7mL7 o+lXxNFkTvg5I7/BDpYafwcpi6BLPnny9NLtJPMgOh9pHM4KN9x7qFrh8gpALevDqPF1 3j2vFw71zEm7WF3MpbIOEQzWLRCghiK832shgpwiWv5ZGQ+jW1pt/UdNfeELkFhjObpK wUiQ== MIME-Version: 1.0 X-Received: by 10.50.169.106 with SMTP id ad10mr8149964igc.88.1358744765493; Sun, 20 Jan 2013 21:06:05 -0800 (PST) Sender: porto143@gmail.com In-Reply-To: References: <2cc6791f-ba56-406c-a5b0-b23023caf4bb@googlegroups.com> Date: Mon, 21 Jan 2013 06:06:05 +0100 X-Google-Sender-Auth: B5ozHT3jHv8rXS695vYHuMI4DtU Subject: Re: Else statement executing when it shouldnt From: =?UTF-8?B?UmVuw6kgS2xhxI1hbg==?= To: eli m Content-Type: multipart/alternative; boundary=e89a8f2346bb16735704d3c56b0e 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 91 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358744774 news.xs4all.nl 6940 [2001:888:2000:d::a6]:45491 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37151 --e89a8f2346bb16735704d3c56b0e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Examples: # else branch will be executed i =3D 0 while i < 5: i +=3D 1 else: print('loop is over') # else branch will be executed i =3D 0 while i < 5: i +=3D 1 if i =3D=3D 7: print('i =3D=3D 7') break else: print('loop is over') # else branch wont be executed i =3D 0 while i < 5: i +=3D 1 if i =3D=3D 3: print('i =3D=3D 3') break else: print('loop is over') On Mon, Jan 21, 2013 at 5:57 AM, eli m wrote: > On Sunday, January 20, 2013 8:54:13 PM UTC-8, Ren=C3=A9 Kla=C4=8Dan 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 > --e89a8f2346bb16735704d3c56b0e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Examples:

# else branch will be executed
i =3D= 0
while i < 5:
=C2=A0 =C2=A0 i +=3D 1
els= e:
=C2=A0 =C2=A0 print('loop is over')


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


# else branch wont be executed
i =3D 0
while i < 5:
=C2=A0 =C2=A0 i +=3D 1<= /div>
=C2=A0 =C2=A0 if i =3D=3D 3:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 print('i =3D=3D 3')
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 break
els= e:
=C2=A0 =C2=A0 print('loop is over')
On Mon, Jan 21, 2013 at 5:57 AM, eli m <t= echgeek201@gmail.com> wrote:
On Sunday, January 20, 201= 3 8:54:13 PM UTC-8, Ren=C3=A9 Kla=C4=8Dan 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

--e89a8f2346bb16735704d3c56b0e--