Hacker News new | ask | show | jobs
by netdog 4447 days ago
My for-real-not-humor implementation:

    def fizzbuzz(i, n):
        while i <= n:
            yield i%15 and (i%5 and (i%3 and i or 'fizz') or 'buzz') or 'fizzbuzz'
            i += 1

    for x in fizzbuzz(1, 100):
        print x
2 comments

Tight, but I'd still use multiple yields, all the conditions in the one liner may be difficult to read.
real oldschool, since you don't use the ternary if that's available since Python 2.5.