0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

412. Fizz Buzz

Posted at

412. Fizz Buzz

よくあるFizzBuzz問題。
list.append()の書き方を忘れていた。

class Solution:
    def fizzBuzz(self, n: int) -> List[str]:
        answer_list = []
        for i in range(1, n + 1):
            if(i % 3 == 0 and i % 5 == 0):
                answer_list.append("FizzBuzz")
            elif(i % 3 == 0):
                answer_list.append("Fizz")
            elif(i % 5 == 0):
                answer_list.append("Buzz")
            else:
                answer_list.append(str(i))
        return answer_list
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?