Generators are extremely useful when we would like to iterate through large or infinite data. The next item is not fetched/calculated until it is explicitly asked for. For example, we could create a generator to generate the next number in the Fibonacci series the following way:
Using such a generator we don't have to calculate and return the entire series of numbers from the function. We can generate the next number in the Fibonacci series on the go. The next number will be generated only when we call next()
.