From 8d8cd4433cb73d933d8f19a25741d7a1ac074715 Mon Sep 17 00:00:00 2001 From: TheForge1029 <130023603+TheForge1029@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:49:13 -0400 Subject: [PATCH] FizzBuzz Challenge --- fizzbuzz.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/fizzbuzz.py b/fizzbuzz.py index 218f7aa..c3b967d 100644 --- a/fizzbuzz.py +++ b/fizzbuzz.py @@ -1,2 +1,21 @@ # add your code here +# Iterate through numbers from 0 to 50 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) \ No newline at end of file