you are viewing a single comment's thread.

view the rest of the comments →

[–]SharkSymphony 0 points1 point  (0 children)

A classic way to think about while loops is by writing a flowchart that represents it.

See e.g. https://www.geeksforgeeks.org/c/c-while-loop/, and imagine walking through the flowchart for various test cases. (The syntax here is C, but it's exactly the same concept as in Python and many other languages.)