Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 45)
45.
How does the generator.send(value) method differ from yield value when used with a generator?
They have the same effect on the generator
generator.send(value) sends a value into the generator, while yield value yields a value from the generator
yield value sends a value into the generator, while generator.send(value) yields a value from the generator
generator.send(value) stops the generator, while yield value continues the generator's execution
Answer: Option
Explanation:
generator.send(value) is used to send a value into the generator, while yield value is used to yield a value from the generator.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.