Home › Interview Questions › In Python, which keyword turns a function into a g…

In Python, which keyword turns a function into a generator?

🟢 Easy Conceptual Fresher level
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