class Solution:
def fizzBuzz(self, n):
"""
:type n: int
:rtype: List[str]
"""
new_list = []
for i in range(n):
if (i+1) % 15 == 0:
new_list.append("FizzBuzz")
elif (i+1) % 3 == 0:
new_list.append("Fizz")
elif (i+1) % 5 == 0:
new_list.append("Buzz")
else:
new_list.append(str(i+1))
return new_list
No comments:
Post a Comment