Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

FizzBuzz

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

Your question is FizzBuzz. 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

At Ultra Mobile, simple sequence generators are often used in interview screens to test clean control flow and edge handling. Implement the classic FizzBuzz logic for the range 1 through n.

Given a positive integer n, return a list of strings representing the numbers from 1 to n inclusive with the following rules:

  1. For multiples of 3, use "Fizz".
  2. For multiples of 5, use "Buzz".
  3. For multiples of both 3 and 5, use "FizzBuzz".
  4. Otherwise, use the number itself as a string.

Constraints

  • 1 <= n <= 10^4
  • Return exactly n strings
  • Each output element must be a string

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