Simple python


  • 0
    K
    class Solution(object):
        def fizzBuzz(self, n):
            """
            :type n: int
            :rtype: List[str]
            """
            results = []
            for i in range(1, n + 1):
                if (i % 3 == 0) and (i % 5) == 0:
                    results.append("FizzBuzz")
                elif (i % 3) == 0:
                    results.append("Fizz")
                elif (i % 5) == 0:
                    results.append("Buzz")
                else:
                    results.append(str(i))
            return results

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.