Python Generator Function
Multiple Choice Medium
Question
What does the `yield` keyword do in a Python function?
Hint
yield is different from return — the function can resume.
Explanation
yield produces a value but pauses the function instead of ending it. When the generator is called again, execution resumes right after the yield. This makes generators memory-efficient for producing large or infinite sequences.
Related Resources
Related Lessons
- Generators
The yield keyword.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.