Menu
Coddy logo textTech

The FizzBuzz Function

Part of the Fundamentals section of Coddy's Python journey — lesson 50 of 77.

challenge icon

Challenge

Easy

Add a function named fizzbuzz that gets one number (int) as an argument, and:

  • If the number is divisible by 3, return "Fizz".
  • If the number is divisible by 7, return "Buzz".
  • If the number is divisible by both 3 and 7, return "FizzBuzz".
  • If none of the above conditions are met, return the number itself in a string format.

After the function:

  • Get input and cast it to int
  • Call the function fizzbuzz with the input number
  • Print the output of the function

Try it yourself

print("Welcome to FizzBuzz!")

def fizzbuzz(number):
    # Write your code here

limit = int(input())
# Print the output of the function

All lessons in Fundamentals