The constructor takes a dictionary which maps numbers to what to print instead of their multiples. Mapping should be a dictionary with numbers as keys and what to print
Here is a fairly simple class calledĪdvancedFizzBuzz which will give us a fully extensible FizzBuzz machine. I feel a more generic approach is needed here. If it's divisible by both 3 and 7, BuzzPop if it's divisible by 5 and 7 andįizzBuzzPop if it's divisible by 3, 5 and 7.Īnd of course if you say that multiples of 11 become Bizz you get into real trouble. If it's divisible by 7, FizzBuzz if it's divisible by both 3 and 5, FizzPop
The number, Fizz if it is divisible by 3, Buzz if it is divisible by 5, Pop # = def fizz_buzz_pop(limit) :įor the each number in 1 - limit inclusivly, this function prints either