Unit 2 Task 30 - Solution

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Solution - Task 30: FizzBuzz inventory labels

← Back to task


One possible program:

max_label = int(input("N: "))

for label_number in range(1, max_label + 1):
    if label_number % 3 == 0 and label_number % 5 == 0:
        print("FizzBuzz")
    elif label_number % 3 == 0:
        print("Fizz")
    elif label_number % 5 == 0:
        print("Buzz")
    else:
        print(label_number)