3 ms·
That's very nice code and Python is non-functional. I love its generators. That's my version to make it more "functional": from itertools import cycle, isli
by twa927 7y ago
That's very nice code and Python is non-functional. I love its generators.
That's my version to make it more "functional":
from itertools import cycle, islice
from operator import add
fizz = cycle(['', '', 'Fizz'])
buzz = cycle(['', '', '', '', 'Buzz'])
strings = map(add, fizz, buzz)
strings_or_nos = (s or i for i, s in enumerate(strings, start=1))
print(list(islice(strings_or_nos, 100)))
- raverbashing 7y agoCool, you just need to join the list with '\n' before printing ;)