Skip to content

Instantly share code, notes, and snippets.

@tusharsadhwani
Created May 4, 2021 20:02
from typing import Generator
def generator(n: int) -> Generator[str, None, int]:
yield 'start'
for i in range(n):
yield f'item number {i+1}'
yield 'end'
return 42
for string in generator(3):
print(string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment