Elizabeth Weiss <cake...@gmail.com> writes:

> Why is one of the results 5 since i=i+1?

What do you think ‘i = i + 1’ means? (Asking because your idea of what
that means may be affecting how you expect the loop to behave.)

> Should the maximum result be 4 since 4 +1=5?

Try “thinking like the computer”: perform the steps yourself, reading
each statement as though you are the computer. Keep a pad and pencil at
hand, and make notes on what changes as you go through. See what
you-as-computer actually emit onto the paper, and see whether that
matches what the Python session produces.

-- 
 \      “The difference between a moral man and a man of honor is that |
  `\   the latter regrets a discreditable act, even when it has worked |
_o__)                   and he has not been caught.” —Henry L. Mencken |
Ben Finney

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

Reply via email to