In Python, which keyword turns a function into a generator?
1Times asked
Aug 2026Last seen
Aug 2026First 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.
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