Python Beginner Code only

FizzBuzz in Python

The classic loop exercise, written clearly.

Updated 5 Oct 2026 9 lines 1 min read

For each number, check divisibility by 15 first, then 3, then 5.

main.py
Download
for n in range(1, 21):
    if n % 15 == 0:
        print("FizzBuzz")
    elif n % 3 == 0:
        print("Fizz")
    elif n % 5 == 0:
        print("Buzz")
    else:
        print(n)
Code only · preview unavailable Python code runs on a server or your own computer, so it is not run here. Copy or download it and try it in your own environment.
Hi there! đź‘‹ Have a question about the courses or joining the class? Ask me.