def gen_123():
print("gen0")
yield 1
print("gen1")
yield 2
print("gen2")
yield 3
print("gen3")
print(gen_123())
for i in gen_123():
print(i)
print(list(gen_123()))
squares = [x ** 2 for x in range(10)]
print(squares)
squares = (x ** 2 for x in range(10))
print(squares)
print(list(squares))
def infinite_sequence():
num = 1
while True:
yield num
num += 1
# for i in infinite_sequence():
# print(i)
print(range(10))
def range_(stop):
i = 0
while i < stop:
yield i
i += 1
for i in range(5):
print(i)
for i in range_(5):
print(i)
print()
r = range_(5)
for i in r:
print(i)
for i in r:
print(i)