Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Generate Fizz Buzz Sequence

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Generate Fizz Buzz Sequence. Start with the requirements on the right.

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.

Problem

Given an integer n, return a list of strings representing the numbers from 1 to n. For multiples of 3, use "Fizz" instead of the number; for multiples of 5, use "Buzz"; and for numbers divisible by both 3 and 5, use "FizzBuzz".

Constraints

  • 1 <= n <= 10^4
  • Return exactly n strings
  • Each output entry must be either the number as a string, "Fizz", "Buzz", or "FizzBuzz"

Function Signature

def fizz_buzz(n):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output