Introdução às Generator functions em Python

This commit is contained in:
Luiz Otávio
2022-11-04 10:17:34 -03:00
parent e52fda4dee
commit 717610667b

15
aula91.py Normal file
View File

@@ -0,0 +1,15 @@
# Introdução às Generator functions em Python
# generator = (n for n in range(1000000))
def generator(n=0, maximum=10):
while True:
yield n
n += 1
if n >= maximum:
return
gen = generator(maximum=1000000)
for n in gen:
print(n)