Loops · Intermediate · 75 XP · about 8 min
The classic programming challenge! Write a function called fizz_buzz(n) that returns a list of strings from 1 to n with the following rules:
fizz_buzz(5) # Returns ["1", "2", "Fizz", "4", "Buzz"] fizz_buzz(15) # Returns ["1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", # "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"]
Ready?
Accept the challenge to start writing. A small timer counts the time this page is in view.
Output appears here.