I'm developing an implementation of the FizzBuzz game as part of an edutainment game for a retro video game platform. In its manual, I want to mention the history of writing a bot for the FizzBuzz game as a programmer screening test since Jeff Atwood's blog post, including sample answers in a few popular programming languages. But I don't want to confuse readers with poorly written code.
So is there anything unclear or unpythonic about my approach to FizzBuzz?
# Each of several divisors has a name. For each number, # print the names of all divisors that divide the number, # if any. Otherwise print the number itself. divs = [ (3, "fizz"), (5, "buzz"), ] for n in range(1, 101): # Make a string containing names of divisors of n ndivs = ''.join(name for (divisor, name) in divs if n % divisor == 0) # If the string is empty, print the number instead print(ndivs or n)