+ 1
How does yield differ from a simple return keyword in functions.
Use of yield
2 Respuestas
+ 6
yield does not destroy the local variables in the function, return does.
+ 2
A function returns a value after executing it's statements
Yield however enables the function to return multiple values for a single function call
Thereby enabling us to create lists by calling the function just once.