Horje
how to catch stop itteration in generator as None Code Example
how to catch stop itteration in generator as None
# creating the list
L = [1,2,3,4,5,6]
# defining the generator
def generator(l):
    for i in l: yield i
    while True: yield  None
        

g = generator(L)

print(next(g)) # 1
print(next(g)) # 2
print(next(g)) # 3
print(next(g)) # 4
print(next(g)) # 5
print(next(g)) # 6
print(next(g)) # None
print(next(g)) # None
print(next(g)) # None




Python

Related
convert to lowercase command python Code Example convert to lowercase command python Code Example
how to put 2 code n 1 line in python Code Example how to put 2 code n 1 line in python Code Example
OneHotEncoder pyspark Code Example OneHotEncoder pyspark Code Example
looping over folder to extract zip winrar python Code Example looping over folder to extract zip winrar python Code Example
how to define the range of values in seaborn heatmap Code Example how to define the range of values in seaborn heatmap Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8