yieldEasy Playground

Pauses a generator function and produces a value to the caller

Python Playground
Output
Click "Run" to execute your code

yield pauses the function and returns a value. When next() is called again, execution resumes after the yield. This creates lazy sequences that compute values on demand.

Challenge

Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?