Use of Generators in Python || Generators || Python

In this we are going to see a basic program on the Use of Generators in Python Programming Language.


def mygenerator():
    print('First item')
    yield 10

    print('Second item')
    yield 20

    print('Last item')
    yield 30


g = mygenerator()
print(next(g))
print(next(g))
print(next(g))

# Coded By Dhiraj Shelke

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post