Association between generators and yield

What is a generator function and what is its association with the yield function.

25th Mar 2017, 8:54 AM
Yashvardhan Shetty
Yashvardhan Shetty - avatar
2 Antworten
+ 3
actually, a generator is a function that contains at least one yield statement
25th Mar 2017, 1:57 PM
Amaras A
Amaras A - avatar
The yield statement is used to define a generator, replacing the return of a function to provide a result to its caller without destroying local variables.
17th Nov 2017, 9:44 PM
Gunther Strauss
Gunther Strauss - avatar