Apr-13-2018, 06:26 AM
General approach for such transforming is the following:
for item in some_iterable: # any python code here # can be rewritten as: while True: try: item = next(some_iterable) except StopIteration: break # any python code here