Advertisement
treyhunner

fizzbuzz generator

Dec 2nd, 2016
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. from itertools import count
  2.  
  3. def fizzbuzz():
  4.     for n in count(1):
  5.         word = ""
  6.         if n % 3 == 0:
  7.             word += "Fizz"
  8.         if n % 5 == 0:
  9.             word += "Buzz"
  10.         yield (word if word else n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement