for / while else doesn't make sense
Lawrence D’Oliveiro
lawrencedo99 at gmail.com
Fri Jun 3 23:43:20 EDT 2016
On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote:
> You can exit a loop because you have run out of items to process, or you can
> exit the loop because a certain condition has been met.
But why should they be expressed differently?
item_iter = iter(items)
while True :
item = next(item_iter, None)
if item == None :
break
if is_what_i_want(item) :
break
#end while
More information about the Python-list
mailing list