Which Python keyword is primarily used in generator functions to yield values?

  • break
  • continue
  • return
  • yield
The yield keyword is used in generator functions to yield values one at a time. It allows the function to pause its execution state and resume it when the next value is requested, making generators memory-efficient and suitable for iterating over large datasets.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *