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

+3

How does "yield" works

https://code.sololearn.com/c40KKqH8zzf7/?ref=app

4/12/2021 9:37:38 PM

Hrushikesh U N

4 Answers

New Answer

+8

# 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}')

+3

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

0

Its yields the processor until next() is called

0