-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfizz_buzz.py
More file actions
28 lines (25 loc) · 780 Bytes
/
fizz_buzz.py
File metadata and controls
28 lines (25 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Print all of the numbers from 1 to 100. However, for any number divisible by three,
print the word “Fizz,” for any number divisible by five, print the word “Buzz,” and
for any number divisible by both three and five, print the word “FizzBuzz.”"""
def fizzbuzz(num):
l=[]
word = " "
for i in range(1,num):
if i%3==0 and i%5==0:
# l.append("FIZZBUZZ")
word="FIZZBUZZ"
elif i%3==0:
# l.append("FIZZ")
word = "FIZZ"
elif i%5==0:
# l.append("BUZZ")
word = "BUZZ"
# else:
# l.append(str(i))
if word!= " ":
l.append(word)
else:
l.append(i)
print(l)
n=int(input("Enter the number :"))
fizzbuzz(n)