In Python, which keyword turns a function into a generator?
1
Times asked
Aug 2026
Last seen
Aug 2026
First seen
💡 Model Answer
The keyword is yield. When a function contains a yield statement, it becomes a generator function. Calling it returns a generator object that can be iterated over, producing values lazily.
Sign in to unlock the rest of this answer
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500