A functional Fizzbuzz implementation

from functools import reduce from itertools import count FACTORS = {3: 'fizz', 5: 'buzz'} fizzbuzz = lambda n: reduce( str.__add__, (FACTORS[d] for d in FACTORS if n % d == 0), "" ) or str(n) print( *map(fizzbuzz, range(1, 31)), sep='\n' )