R

Rati Dubey • 8.55K Points
Tutor III

Q. Which keyword is used to define a generator function in Python?

  • (A) return
  • (B) yield
  • (C) generate
  • (D) iter
  • Correct Answer - Option(B)
  • Views: 10
  • Filed under category Python

Explanation by: Rati Dubey
The `yield` keyword turns a function into a generator, which can produce values one at a time.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics