# iterators - fetch one value at a time; use iter() and next()
# generators - use yield instead of return in a func
'''
x = [1,2,3,4,5]
res = iter(x)
print(res.__next__())
print(res.__next__())
print(next(res))
'''

def gen(n): # instead of storing all values ,it stores only one value in cache at a time
    for i in range(n):
        yield i
res = gen(6)
print(res)
print(res.__next__())
print(next(res))

bee9cc1366530724c0f17f8d933ecf44f5fa1624
<mask token>

<mask token>


def gen(n):
    for i in range(n):
        yield i


<mask token>

<mask token>


def gen(n):
    for i in range(n):
        yield i


<mask token>
print(res)
print(res.__next__())
print(next(res))

<mask token>


def gen(n):
    for i in range(n):
        yield i


res = gen(6)
print(res)
print(res.__next__())
print(next(res))

# iterators - fetch one value at a time; use iter() and next()
# generators - use yield instead of return in a func
'''
x = [1,2,3,4,5]
res = iter(x)
print(res.__next__())
print(res.__next__())
print(next(res))
'''

def gen(n): # instead of storing all values ,it stores only one value in cache at a time
    for i in range(n):
        yield i
res = gen(6)
print(res)
print(res.__next__())
print(next(res))
