What turns an ordinary Python function into a generator function?
Correct answer B. Using the yield keyword in its body
Explanation
Any function whose body contains yield is a generator function. Calling it returns a generator object, and each yield pauses execution and hands a value back, resuming from that point on the next request. Python has no @generator decorator, and returning a list builds all values at once.
Answer checked How we write and check questions
Discussion