From 61ad75468987826f78414a532eb4f1528987c387 Mon Sep 17 00:00:00 2001 From: Whitney Parks Date: Sun, 3 Nov 2024 20:34:31 -0500 Subject: [PATCH] updated fizzbzz.py --- fizzbuzz.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/fizzbuzz.py b/fizzbuzz.py index 218f7aa..6b1114a 100644 --- a/fizzbuzz.py +++ b/fizzbuzz.py @@ -1,2 +1,20 @@ -# add your code here +# Iterate through numbers from 0 to 100 using the range function +for fizzbuzz in range(101): + # Check if the current number is divisible by both 3 and 5 (i.e., divisible by 15) + if fizzbuzz % 3 == 0 and fizzbuzz % 5 == 0: + # If divisible by both 3 and 5, print "fizzbuzz" and continue to the next iteration + print("fizzbuzz") + continue + # Check if the current number is divisible only by 3 + elif fizzbuzz % 3 == 0: + # If divisible only by 3, print "fizz" and continue to the next iteration + print("fizz") + continue + # Check if the current number is divisible only by 5 + elif fizzbuzz % 5 == 0: + # If divisible only by 5, print "buzz" and continue to the next iteration + print("buzz") + continue + # If the number is neither divisible by 3 nor 5, print the number itself + print(fizzbuzz)