When to use yield instead of return in Python? - GeeksforGeeks
The yield statement suspends function's execution and sends a value back to caller, but retains enough state to enable function to resume where it is left off. When resumed, the function continues execution immediately after the last yield run. This allows its code to produce a series of values over time, rather them computing them at once and sending them back like a list.
Read full article from When to use yield instead of return in Python? - GeeksforGeeks
No comments:
Post a Comment