How does "yield" works | Sololearn: Learn to code for FREE!


How does "yield" works

4/12/2021 9:37:38 PM

Hrushikesh U N

4 Answers

New Answer


# a simple enumeration example def generator(): i = 1 while True: yield i i += 1 g = generator() l = ('Anton', 'Berta', 'Claire', 'David', 'Eveline') for i in l: print(f'{next(g)}: {i}')


Yield is a return measure for an investment over a set period of time, expressed as a percentage. 


Its yields the processor until next() is called