[SNIPPED]
>
> Always use a while loop in this situation,

This is excellent advice. Use a for loop in two
situations:
 1. Iterating a fixed(known) number of times
 2. Iterating through the contents of any container

Use a while loop to iterate as long as a condition applies.


> regardless of whether or not
> teachers put stupid artificial constraints on your code,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> such as banning the use of len().

There may be legitimate learning outcomes for a teacher
to specify such conditions.
In this case, learning to use a counter that is incremented
under certain conditions. I would hesitate to condemn in
such strong terms without knowing more background.

Asokan Pichai
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to