• Save
  • Run All Cells
  • Clear All Output
  • Runtime
  • Download
  • Difficulty Rating

Loading Runtime

Write a function called fizz_buzzer that takes an integer num_items as an argument.

This function should return a list of length num_items.

The list should contain all positive integers from 1 to num_items (inclusive). However...

  • If an integer in the list is divisible by 3, replace it with the string "fizz".
  • If an integer is divisible by 5 replace it with the string "buzz".
  • If an integer is divisible by both 3 and 5 replace it with the string "fizzbuzz".

Example:

fizzbuzzer(15)

Returns: [1, 2, 'fizz', 4, 'buzz', 'fizz', 7, 8, 'fizz', 'buzz', 11, 'fizz', 13, 14, 'fizzbuzz']

Reset Code