Python 101 : Changing the behavior of the "range()" function

We create an custom iterator function that we will use with a "for" loop:

We use it as below:

The "yield" function acts as a return function but it doesn't completely  exit the function - the control is not handed back completely to the caller of the function - and the next instruction in the function is run:


Leave as a comment: