''' Created on Mar 17, 2016 @author: Brett Paufler Copyright Brett Paufler ''' from itertools import count def fizz_buzz(): '''A generator solution for the infamous fizz-buzz interview question.''' for num in count(1): if num % 15 == 0: text = 'Fizz-Buzz!!!' elif num % 5 == 0: text = 'fizz' elif num % 3 == 0: text = 'buzz' else: text = str(num) yield text fizz_buzzer = fizz_buzz() for n in range(1, 16, 1): print next(fizz_buzzer), #Copied Wholesale from Reddit print '\nFrom Reddit' for x in range(1,101):print'Fizz'*(x%3==0)+'Buzz'*(x%5==0)or x,