1. Home
  2. Data Science
  3. Python
  4. Which keyword turns a function into a generator in Python?

Added 25 Nov 2026

Which keyword turns a function into a generator in Python?

  1. return
  2. generate
  3. yield Correct answer
  4. lazy

Correct answer

C. yield

6 views

MCQSEXAM

Explanation

A function containing yield returns a generator object when called.

Reference

Asked in: Python Interview Advanced Python

https://docs.python.org/3/library/index.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs