for / while else doesn't make sense
Lawrence D’Oliveiro
lawrencedo99 at gmail.com
Thu Jun 2 21:08:10 EDT 2016
On Friday, June 3, 2016 at 8:09:21 AM UTC+12, Rob Gaddi wrote:
> Although your loop is really the _canonical_ use case for
>
> for loopvar in range(initial_value, limit+1):
> processing
> if found_what_im_looking_for:
> break
> else:
> do_whatever_it_is_you_do_when_its_not_found
The reason why I don’t like this is that there are two ways out of the Python for-statement, and they are written quite differently. Why the asymmetry? Logically, all ways out of a loop are of equal significance.
More information about the Python-list
mailing list