Skip to content

Commit 197e53d

Browse files
huntober code challenges in python 2023
1 parent aadf8ce commit 197e53d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

huntober2023/fizzbuzz.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Given a number as an input, print out every integer from 1 to that number. However, when the integer is divisible by 3, print out “Fizz”; when it’s divisible by 5, print out “Buzz”; when it’s divisible by both 3 and 5, print out “Fizz Buzz”.
2+
3+
# input is a number integer
4+
# output are strings
5+
# 15 = "Fizz Buzz"
6+
# 3 = "Fizz"
7+
# 5 = "Buzz"
8+
9+
def fizz_buzz_printer(num):
10+
for n in range(num):
11+
if n % 5 == 0 and n % 3 == 0 and n != 0:
12+
print("Fizz Buzz")
13+
elif n % 3 == 0:
14+
print("Fizz")
15+
elif n % 5 == 0:
16+
print("Buzz")
17+
# print(n)
18+
19+
20+
print(fizz_buzz_printer(16))

0 commit comments

Comments
 (0)