Week 2 Bonus Exercise

22. October 2024

Write a Python program that prints the numbers from 1 to 100. If the number is dividable by 3 print Fizz, if the number is dividable by 5 print Buzz instead of the number. If the number is dividable by 3 and 5 print FizzBuzz.

Below is the output of the program for the first 15 numbers:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz

Can you use a list comprehension to solve this exercise?


< Previous unit | Next unit > | Course Overview