0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Python】偶数のリストを返すアルゴリズム

Posted at

はじめに

偶数のリストを返すアルゴリズムです。
(例)input: 20, output: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

実装

even_numbers.py
from typing import List
def func(num: int) -> List[int]:
  numbers = []
  for i in range(num+1):
    if i%2 == 0:
      numbers.append(i)
    else:
      continue
  return numbers

if __name__ == "__main__":
  num = 20
  print(func(20))
0
1
1

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?