2 ms·
It seems like I'm missing a joke. Is this style in homage to the linked-to page? I can't figure out why you're not using itertools nor re-using itertools name
by eesmith 4y ago
It seems like I'm missing a joke.
Is this style in homage to the linked-to page? I can't figure out why you're not using itertools nor re-using itertools names. Is it that translating from .. is that Haskell? .. to Python without idiomatic translation the subversion?
from itertools import islice, cycle
def fizzbuzz():
return (a + b or str(c) for c, (a, b) in enumerate(zip(
cycle(("", "", "Fizz")),
cycle(("", "", "", "", "Buzz")),
), start = 1))
>>> print(*islice(fizzbuzz(), 0, 30))
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz