10FizzBuzz

    Easyloopsconditions

    Write fizzbuzz(n) that returns a list of strings for the numbers 1 to n.

    Use "Fizz" for multiples of 3, "Buzz" for multiples of 5, "FizzBuzz" for multiples of both, and the number itself (as a string) otherwise.

    Examples

    Example 1
    >>> fizzbuzz(5)
    ['1', '2', 'Fizz', '4', 'Buzz']
    Example 2
    >>> fizzbuzz(15)
    ['1', '2', 'Fizz', '4', 'Buzz', 'Fizz', '7', '8', 'Fizz', 'Buzz', '11', 'Fizz', '13', '14', 'FizzBuzz']

    Run examples checks the 2 examples above. Submit runs all 5 tests, including hidden edge cases, and marks the challenge solved.

    solution.py
    Loading Python…

    Test results show up here

    Write fizzbuzz in the editor, then run the examples. Use print() freely: its output is shown for each test.