Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 92)
92.
How does the itertools.dropwhile() function differ from itertools.takewhile() when used with generators?
They are equivalent in functionality
itertools.dropwhile() skips elements until a specified condition becomes false, while itertools.takewhile() yields elements as long as the condition is true
itertools.takewhile() skips elements until a specified condition becomes false, while itertools.dropwhile() yields elements as long as the condition is true
itertools.dropwhile() and itertools.takewhile() both raise a ValueError
Answer: Option
Explanation:
itertools.dropwhile() skips elements until a specified condition becomes false, while itertools.takewhile() yields elements as long as the condition is true.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.