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


Groups > comp.lang.python > #110323

Re: while Loops

From John Gordon <gordon@panix.com>
Newsgroups comp.lang.python
Subject Re: while Loops
Date 2016-06-22 16:03 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <nkecrm$40c$1@reader1.panix.com> (permalink)
References <0cf9a94e-b84c-460d-b03d-edf6a941adc0@googlegroups.com>

Show all headers | View raw


In <0cf9a94e-b84c-460d-b03d-edf6a941adc0@googlegroups.com> Elizabeth Weiss <cake240@gmail.com> writes:

> Why is one of the results 5 since i=i+1? Should the maximum result
> be 4 since 4 +1=5? 

"while i<=5" means "while i is less than or equal to 5".  So the loop
will keep going at 5, and only stop when i is 6.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

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


Thread

while Loops Elizabeth Weiss <cake240@gmail.com> - 2016-06-21 20:50 -0700
  Re: while Loops Wildman <best_lay@yahoo.com> - 2016-06-21 23:04 -0500
  Re: while Loops Rustom Mody <rustompmody@gmail.com> - 2016-06-21 21:04 -0700
  Re: while Loops Ben Finney <ben+python@benfinney.id.au> - 2016-06-22 14:02 +1000
  Re: while Loops Michael Torrie <torriem@gmail.com> - 2016-06-21 22:11 -0600
  Re: while Loops alister <alister.ware@ntlworld.com> - 2016-06-22 08:37 +0000
  Re: while Loops John Gordon <gordon@panix.com> - 2016-06-22 16:03 +0000

csiph-web