In this video, you will learn Generator function in Python.
Generator in Python:
1. Generator is a function that returns an object (iterator) which we can iterate over (one value at a time).
2. A generator-function is defined like a normal function, but whenever it needs to generate a value, it does so with the yield keyword rather than return.
3. If the body of a def contains yield, the function automatically becomes a generator function.
4. Generator functions return a generator object. Generator objects are used either by calling the next method on the generator object or using the generator object in a “for in” loop.
5. "return" statement terminates a function entirely and "yield" statement pauses the function saving all its states and later continues from there on successive calls.
On this page of the site you can watch the video online Generator function in Python | Python Generator Function | Yield Keyword | Python Tutorials with a duration of hours minute second in good quality, which was uploaded by the user GSS 17 January 2021, share the link with friends and acquaintances, this video has already been watched 32 times on youtube and it was liked by 1 viewers. Enjoy your viewing!