Dashboard Temp Share Shortlinks Frames API

HTMLify

index.py
Views: 3 | Author: devwajahat
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
class Solution:
    def fizzBuzz(self, n: int) -> list[str]:

        answer = []
        for i in range(1,n+1):
            if i % 3 == 0 and i % 5 == 0:
                answer.append("FizzBuzz") 
                
            elif i % 5 == 0:
                answer.append("Buzz")
            elif i % 3 == 0:
                answer.append("Fizz")
                
            else:
                answer.append(str(i))
        return answer