In <[email protected]> Elizabeth Weiss
<[email protected]> 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
[email protected] B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
--
https://mail.python.org/mailman/listinfo/python-list