Fizz Buzz
Advanced
Fizz Buzz Challenge
It's time to play a little game called Fizz Buzz! In this game, you will write a function that receives a positive integer n and returns a list of strings representing numbers from 1 to n. But there's a twist!
Here's the rule:
- For multiples of 3, return "Fizz" instead of the number.
- For multiples of 5, return "Buzz" instead of the number.
- For numbers which are multiples of both 3 and 5, return "FizzBuzz".
- For all other numbers, return the number itself as a string.
This game's simple and fun logic challenge will help us practice loops, conditions, and list manipulations in Python.
Examples:
fizz_buzz(3) # Returns: ["1", "2", "Fizz"] 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"]
Are you ready to take on this challenge? Let's have some fun with Fizz Buzz!
Inputs
Arg 1:
3Expected Output
["1", "2", "Fizz"]Actual Output