-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFizz.py
More file actions
23 lines (19 loc) · 685 Bytes
/
Fizz.py
File metadata and controls
23 lines (19 loc) · 685 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 6) FizzBuzz problem. Given a start value S and an end value E, return an array
# containing the values between S and E (inclusive). Replace any integer that
# is a multiple of 3 with the string "Fizz", and multiple of 5 with the string
# "Buzz", and any multiple of 3 and 5 with the string "FizzBuzz".
# For example, given (5, 15), the returned array would be:
# ["Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14, "FizzBuzz"]
array = [ ]
S = 0
E = 56
for s in range(S, E+1):
if not s % 15:
array.append(str("FizzBuzz"))
elif not s % 3:
array.append(str("Fizz"))
elif not s % 5:
array.append(str("Buzz"))
else:
array.append(s)
print(array)