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