Python Programming - Generators - Discussion
Discussion Forum : Generators - General Questions (Q.No. 99)
99.
What does the
yield from
statement do when used in a generator?
Answer: Option
Explanation:
yield from
is used to delegate part of the generator's operation to another generator or iterable. It simplifies the syntax for generators that yield from another iterable.
def generator_delegator():
yield from range(3)
yield from 'abc'
result = list(generator_delegator())
print(result) # Output: [0, 1, 2, 'a', 'b', 'c']
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers