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)]