Menu
Coddy logo textTech

Looping The Numbers

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

challenge icon

Challenge

Easy

Loop over the numbers from 1 to the number that the user entered, and each time use the function you created to calculate the FizzBuzz result and output it.

For example, for input of 7 output:

Welcome to FizzBuzz!
1
2
Fizz
4
5
Fizz
Buzz

Try it yourself

print("Welcome to FizzBuzz!")

def fizzbuzz(number):
    if number % 3 == 0 and number % 7 == 0:
        return "FizzBuzz"
    elif number % 3 == 0:
        return "Fizz"
    elif number % 7 == 0:
        return "Buzz"
    else:
        return str(number)

limit = int(input())
print(fizzbuzz(limit))

All lessons in Fundamentals