Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 17)
17.
In Python, what happens if a generator function contains an infinite loop?
The generator will raise a RuntimeError
The program will go into an infinite loop
The generator will only produce a single value
The generator will continue to yield values indefinitely
Answer: Option
Explanation:
If a generator function contains an infinite loop, it will continue to yield values indefinitely, and you need to handle stopping the iteration explicitly.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.