Last active
December 26, 2015 20:19
-
-
Save ipartola/7207829 to your computer and use it in GitHub Desktop.
FizzBuzz using Python generators
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 fizz(): | |
while True: | |
yield '' | |
yield '' | |
yield 'fizz' | |
def buzz(): | |
while True: | |
yield '' | |
yield '' | |
yield '' | |
yield '' | |
yield 'buzz' | |
f = fizz() | |
b = buzz() | |
for i in range(1, 101): | |
print((f.next() + b.next()) or i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment