Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
FizzBuzz Diagram in Code
00:00
5 left

FizzBuzz Diagram in Code

EasyPython

Problem

Diagram Fizzbuzz in your preferred language.

Implement fizz_buzz(n) to return a list for every integer from 1 through n. Return "Fizz" for multiples of 3, "Buzz" for multiples of 5, "FizzBuzz" for multiples of both, and the number as a string otherwise. Check the combined condition before the individual conditions.

Input: one positive integer n. Output: a list of strings.

Constraints

  • 1 <= n <= 10^4
  • Return exactly n strings
  • The output must be ordered from 1 through n

Function Signature

def fizz_buzz(n):
Interviewer

Your question is FizzBuzz Diagram in Code. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.