PRACTICE / UNDERSTAND / REPEAT

Python practice question

Practice generators with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

1 questionAnswers explainedFree · no login

Try this question

Generators · MCQQuestion link ↗

What does `yield` do inside a function?

Choose one answer
Answer & explanation

Answer: Produces a value and suspends the generator

`yield` produces a value while preserving generator state for the next iteration.