Yield Keyword Python || Generators || Python

 

In this we are going to see how write a code about Yield Keyword Python, using Generators in Python Programming Language.


def foo():
    print("begin")
    for i in range(3):
        print("before yield", i)
        yield i
        print("after yield", i)
    print("end")

f = foo()
print(next(f))
print(next(f))
print(next(f))

# 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