while Loops

John Gordon gordon at panix.com
Wed Jun 22 12:03:02 EDT 2016


In <0cf9a94e-b84c-460d-b03d-edf6a941adc0 at googlegroups.com> Elizabeth Weiss <cake240 at 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 at panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"



More information about the Python-list mailing list