AKUNA CAPITAL Interview Question

What is the 'yield' keyword in python?

Interview Answer

Anonymous

Apr 9, 2018

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.