In <639b00e0-7b9d-4ed4-96ad-6afbcd536...@googlegroups.com> Elizabeth Weiss 
<cake...@gmail.com> writes:

> i=0
> while 1==1:
>    print(i)
>    i=i+1
>    if i>=5:
>      print("Breaking")
>      break

> Why is Breaking going to be printed if i only goes up to 4?

Your code prints i and THEN adds one to it.

So i is 4, it gets printed, then 1 is added to it, so it becomes 5
and then the loop exits.

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

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to