```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ``` ```#! /usr/bin/env python3 # fizzbuzz.py def divisor_response(divisor, response): # say fizz if the number is divisible by 3 return lambda n: "" if n % divisor != 0 else response def arbitrary_divisor_responses(d_responses): # combine fizzbuzz responses in a specific order # or say the number if none of them apply return lambda n: "".join( [divisor_response(*s)(n) for s in d_responses] ) or str(n) def fizzbuzz(n): # actual fizzbuzz return arbitrary_divisor_responses([ (3, "fizz"), (5, "buzz")])(n) def fb_start_end(start, end): # fizzbuzz within a range return "\n".join([ fizzbuzz(n) for n in range(start, end+1)]) if __name__ == "__main__": print(fb_start_end(1, 100)) ```
 ```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ``` ```1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizzbuzz 16 17 fizz 19 buzz fizz 22 23 fizz buzz 26 fizz 28 29 fizzbuzz 31 32 fizz 34 buzz fizz 37 38 fizz buzz 41 fizz 43 44 fizzbuzz 46 47 fizz 49 buzz fizz 52 53 fizz buzz 56 fizz 58 59 fizzbuzz 61 62 fizz 64 buzz fizz 67 68 fizz buzz 71 fizz 73 74 fizzbuzz 76 77 fizz 79 buzz fizz 82 83 fizz buzz 86 fizz 88 89 fizzbuzz 91 92 fizz 94 buzz fizz 97 98 fizz buzz ```