class Solution:
def fizzBuzz(self, n):
"""
:type n: int
:rtype: List[str]
"""
res = []
for i in range(1, n+1):
if i%3 == 0:
if i%5 == 0:
res.append('FizzBuzz')
else:
res.append('Fizz')
elif i%5 == 0:
res.append('Buzz')
else:
res.append(str(i))
return res
Python, LeetCode, 412. Fizz Buzz
最新推荐文章于 2022-07-06 15:28:41 发布