Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 34)
34.
How does the generator.send(value) method differ from next(generator) when used with a generator?
They are equivalent in functionality
generator.send(value) initializes the generator, while next(generator) retrieves the next value
next(generator) can be used without a value, while generator.send(value) requires a value
generator.send(value) returns the value sent, while next(generator) does not
Answer: Option
Explanation:
next(generator) can be used without providing a value, while generator.send(value) requires a value to be sent into the generator.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.