Skip to content

Instantly share code, notes, and snippets.

View andrealmar's full-sized avatar
🏠
Working from home

Andre Almar andrealmar

🏠
Working from home
View GitHub Profile
list_comprehension = [1,2,3,4,5,6,7,8]
>>> for item in generator():
... print(item)
...
Essa é uma função Generator
1
2
3
>>
>>> # Quando a função termina, a exceção StopIteration é levantada automaticamente.
>>> next(a)
Traceback (most recent call last):
...
StopIteration
>>> next(a)
Traceback (most recent call last):
...
StopIteration
def generator():
n = 1
print("Essa uma função Generator")
yield n
n += 1
yield n
n += 1
yield n