Unlike ordinary functions or methods that use the return statement to return a single value, a
generator is a mechanism that produces a sequence of zero
or more values. Each execution of a yield
statement produces an additional value. To signal the
caller that there are no more values, use this raise statement: