leetcode-412

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


class Solution(object):
def fizzBuzz(self, n):
"""
:type n: int
:rtype: List[str]
"""
get_list = []
for i in range(1, n+1):

my_item = "Fizz"[i%3*4::]+"Buzz"[i%5*4::] or str(i)
get_list.append(my_item)

return get_list

# 一行代码
# return ["Fizz"*(not i%3)+"Buzz"*(not i%5) or str(i) for i in range(1,n+1)]