Skip to content

Commit e873db5

Browse files
authored
Create 412_fizz_buzz.py
1 parent 843479b commit e873db5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

412_fizz_buzz.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def fizzBuzz(self, n: int) -> List[str]:
3+
answer = []
4+
5+
for i in range(1, (n+1)):
6+
if ((i % 3) == 0) and ((i % 5) == 0):
7+
answer.append("FizzBuzz")
8+
elif (i % 3) == 0:
9+
answer.append('Fizz')
10+
elif (i % 5) == 0:
11+
answer.append('Buzz')
12+
else:
13+
answer.append(f'{i}')
14+
15+
return answer

0 commit comments

Comments
 (0)