What does generator.close() do in Python?
Correct answer
D. Raises GeneratorExit inside the generator to end it
10 views
D. Raises GeneratorExit inside the generator to end it
10 views
close() stops the generator by raising GeneratorExit at the paused yield.
Asked in: Python Interview Advanced
https://docs.python.org/3/library/index.htmlNot sure why the answer is D? Ask here and get an explanation.