mycode 99.06%
class Solution(object):
def fizzBuzz(self, n):
"""
:type n: int
:rtype: List[str]
"""
ops = ['Fizz','Buzz','FizzBuzz']
res = []
for i in range(n):
k = i + 1
if k%3 == 0 and k%5 == 0:
res.append(ops[2])
elif k%3 == 0 :
res.append(ops[0])
elif k%5 == 0:
res.append(ops[1])
else:
res.append(str(k))
return res
手机扫一扫
移动阅读更方便
你可能感兴趣的文章