Skip to main content

Program to demonstrate Generators in Python

· One min read
Kaustubh Kulkarni

Que > Program to demonstrate Generators in Python

file.py
def func(a):
yield a
a=[1,2,3]
b=func(a)
next(b)
Output
[1, 2, 3]