Last active
May 5, 2019 21:19
-
-
Save att288/4a264cc2121cedc5bfd64aa9aec67673 to your computer and use it in GitHub Desktop.
generator_send.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multiplier(n): | |
step = None | |
result = 1 | |
for i in range(1, n+1): | |
if step is None: | |
step = 1 | |
result *= (i*step) | |
print(f"i:{i}, step={step}") | |
step = yield result | |
my_generator = multiplier(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment