
Shobha
The best way to predict the future is to invent it
What is a generator in Python and how does it work?
A generator in Python is a function that creates an iterator. It yields values one at a time, using the yield keyword, which allows for on-demand value production and is more memory efficient compared to returning all values at once.