Iteration, while loop, and for loop

Michael Selik michael.selik at gmail.com
Tue Jun 28 09:15:47 EDT 2016


On Tue, Jun 28, 2016 at 8:41 AM Elizabeth Weiss <cake240 at gmail.com> wrote:

> I do not understand the second code. What is counter?
>

It looks like someone wanted to make a loop induction variable.
https://en.wikipedia.org/wiki/Induction_variable


> Why do we use this code if we can use the simpler for loop?
>

You should not. Use the first version, it's much better. Python for-loops
are preferable to while-loops.



More information about the Python-list mailing list