Chrome Extension

[Python] Simple yield generator example

# Generator function
def generator(count):
        i = 0
        while i < count:
            yield i
            i += 1

def test_generator():
    for value in generator(4):
        print("\nGenerated value :", value)
    pass
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Output
Generated value : 0

Generated value : 1

Generated value : 2

Generated value : 3
Was this helpful?
0 Comments
Join Devsheet Ask a Question