Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: while Loops Date: Wed, 22 Jun 2016 14:02:03 +1000 Lines: 21 Message-ID: References: <0cf9a94e-b84c-460d-b03d-edf6a941adc0@googlegroups.com> <85twglx45g.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de 7+qRqSQ26gfhBN5j+lxgPAqrZ61f4JGbyezqzZSu0RfA== Cancel-Lock: sha1:4O4/tCBica6wK8W7co+Xs/YrVCc= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.045 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.01; 'matches': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:while': 0.09; 'through.': 0.09; 'python': 0.10; 'emit': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'changes': 0.20; 'latter': 0.22; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'idea': 0.28; 'act,': 0.29; 'computer.': 0.32; 'statement': 0.32; 'worked': 0.34; 'should': 0.36; 'notes': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'received:org': 0.37; 'difference': 0.38; 'means': 0.39; 'why': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'maximum': 0.61; 'between': 0.65; 'results': 0.66; 'elizabeth': 0.72; 'yourself,': 0.72; '_o__)': 0.84; 'mencken': 0.84; 'received:125': 0.84; '\xe2\x80\x94henry': 0.84; '\xe2\x80\x9cthe': 0.93; 'hand,': 0.97 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <85twglx45g.fsf@benfinney.id.au> X-Mailman-Original-References: <0cf9a94e-b84c-460d-b03d-edf6a941adc0@googlegroups.com> Xref: csiph.com comp.lang.python:110288 Elizabeth Weiss writes: > Why is one of the results 5 since i=i+1? What do you think ‘i = i + 1’ means? (Asking because your idea of what that means may be affecting how you expect the loop to behave.) > Should the maximum result be 4 since 4 +1=5? Try “thinking like the computer”: perform the steps yourself, reading each statement as though you are the computer. Keep a pad and pencil at hand, and make notes on what changes as you go through. See what you-as-computer actually emit onto the paper, and see whether that matches what the Python session produces. -- \ “The difference between a moral man and a man of honor is that | `\ the latter regrets a discreditable act, even when it has worked | _o__) and he has not been caught.” —Henry L. Mencken | Ben Finney