0

I'm trying to get the value from return when using yield with it as shown below:

def test():
    yield 'One'
    yield 'Two'
    yield 'Three'    
    return 'Four' # Here

for x in test():
    print(x)

But, I couldn't get the value Four from return as shown below:

One
Two
Three

So, how can I get the value from return when using yield with it?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129

0 Answers0