Skip to content

Commit

Permalink
Create fizzbuzz.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rerichardjr authored Sep 26, 2023
1 parent b8238fd commit 76e2dc0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions fizzbuzz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution:
def fizzBuzz(self, n: int) -> List[str]:
answer = []
for i in range(1,n+1) :
mod3 = i % 3
mod5 = i % 5
if (mod3 == 0) and (mod5 == 0) :
answer.append("FizzBuzz")
continue
if mod3 == 0 :
answer.append("Fizz")
continue
if mod5 == 0 :
answer.append("Buzz")
continue
answer.append(str(i))
return answer

0 comments on commit 76e2dc0

Please sign in to comment.