Created
July 9, 2014 09:17
-
-
Save yassu/9ed436a88e5bcd136e2e to your computer and use it in GitHub Desktop.
fizzbuzz
This file contains hidden or 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
#!/usr/bin/env python3 | |
def fizzbuzz(): | |
""" generator of fizzbuzz """ | |
i = 1 | |
while True: | |
s = '' | |
if i % 3 == 0: | |
s += 'Fizz ' | |
if i % 5 == 0: | |
s += 'Buzz' | |
if s == '': | |
s = str(i) | |
s = s.rstrip() | |
yield s | |
i += 1 | |
if __name__ == '__main__': | |
from sys import argv | |
num = argv[1] | |
num = int(num) | |
gen = fizzbuzz() | |
for i in range(num): | |
print(next(gen), end=', ') | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment