Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
FizzBuzz Conditions
00:00
5 left

FizzBuzz Conditions

EasyPython

Problem

Write the FizzBuzz logic that prints Fizz and Buzz under certain conditions.

Implement def fizz_buzz(n): to process integers from 1 through n and return a list of strings. For multiples of 3, return "Fizz"; for multiples of 5, return "Buzz"; for multiples of both, return "FizzBuzz"; otherwise, return the number as a string.

Constraints

  • 1 <= n <= 1000
  • The output contains exactly n strings
  • Numbers are processed in ascending order from 1 through n

Function Signature

def fizz_buzz(n):
Interviewer

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