Generator Example 1

Question

Example of a generator.

Solution

def foo():
    print 'hello'
    yield 1
    print 'world'
    yield 2
Run this
Comments by Disqus