while Loops

alister alister.ware at ntlworld.com
Wed Jun 22 04:37:07 EDT 2016


On Tue, 21 Jun 2016 20:50:24 -0700, Elizabeth Weiss wrote:

> i=1 while i<=5:
>    print(i)
>    i=i+1
> 
> The result is:
> 1
> 2
> 3
> 4
> 5
> 
> Why is one of the results 5 since i=i+1? Should the maximum result be 4
> since 4 +1=5?
> 
> Thanks for your help!

check you loop condition
while i lest than or equal to 5

so the loop will run for the case when i= 5 




-- 
Welcome to Utah.
If you think our liquor laws are funny, you should see our underwear!


More information about the Python-list mailing list