From cbf35b36b2b40c1758c3e6feb48c72e20f74cd33 Mon Sep 17 00:00:00 2001 From: Cristina Nguyen Date: Thu, 29 Oct 2020 14:47:36 -0700 Subject: [PATCH] add fizzbuzz solution --- fizzbuzz.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 fizzbuzz.py diff --git a/fizzbuzz.py b/fizzbuzz.py new file mode 100644 index 0000000..51a3585 --- /dev/null +++ b/fizzbuzz.py @@ -0,0 +1,15 @@ +# write a function that completes the following +# For multiples of 3, print "fizz" +# For multiples of 5, print "buzz" +# For multiple of both 3 and 5 print "FizzBuzz" + +def fizzbuzz(n): + for i in range (1, n+1): + if i % 3 == 0 and i % 5 == 0: + print (i, "- FizzBuzz") + elif i % 5 == 0: + print (i, "- buzz") + elif i % 3 == 0: + print (i, "- fizz") + +fizzbuzz(20)