1
0

More than 3 years have passed since last update.

rangeで指定する範囲の数字のリストを作成

Last updated at Posted at 2021-08-19

指定する範囲の数字のリスト(昇順)を作成

a = list(range(1,10,2))
print(a)
#実行結果
[1, 3, 5, 7, 9]

第一引数: start(含む) デフォルトは0、省略可
第二引数: end(含まない) 省略不可
第三引数: 幅 デフォルトは1、省略可

降順のリストを作成

a = list(range(10,0,-1))
print(a)
#実行結果
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
1
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
1
0