+ 2
What is the diference between RETURN and YIELD?
3 Answers
+ 4
I think the main difference between RETURN and YIELD is that RETURN only returns value once (after RETURN statement, the code will stop running) while YIELD is quite similar with RETURN but it returns value multiple times (depends on the number of your iterations). Try assign a yield function to a variable and return function to another one (use iteration for both func), you might understand the difference.
+ 2
In short: yield is a keyword that is used like return, except the function will return a generator.
+ 1
What does generator exactly means