#python Generators Explained ! (Sort of)
▻https://hackernoon.com/python-generators-35ac68334882?source=rss----3a8144eabfe3---4
Learn python generators by example.GENERATORSAs IteratorsUsing generators (generator functions)>>> def integers(): i = 1 while True: yield i i = i + 1>>> a = integers()>>> next(a)1>>> next(a)2>>> next(a)3>>> next(a)4>>> next(a)5>>>Assigning a #generator to a varialble will automatically create ._next_() or next(generator) methodThis will allow you to iterate through the generator valuesConverting to list>>> def yrange(n): i = 0 while i < n: yield i i += 1>>> y = yrange(5)>>> list(y)[0, 1, 2, 3, 4]>>> list(y)[]You can convert a generator to a list however on the process it will lose its value and transfer it to the list.>> y = (...)