Generators are one of the tools that helps in code optimization. They give you a nice way of generating data structure that delivers values when required and not filling the memory with all possible values where most of them may not be used.
There are inbuilt generators that comes with python, but learning how to built yours is very easy and a better alternatives to iterators. In this video, i explained how generators are different from iterators and how the process of building one requires just the knowledge of functions and a little twist.
Have fun and don't forget to subscribe to the channel if you haven't already. See you in the next one.