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 3 years have passed since last update.

Python、for〜(range)について

Last updated at Posted at 2020-03-23

###for文のrange関数についてメモ

・range(n)は、0からn−1の整数列
・range(n,m)は、nからm-1の整数列
・range(n,m,k)は、nからm-1の公差p

for i in range(10):
    print(i)
0
1
2
3
4
5
6
7
8
9

iに1から9の値を代入している。

for i in range(4,10):
    print(i) 
4
5
6
7
8
9

iに4から9までの値を代入している。

for i in range(4,10,2):
    print(i)
4
6
8

iに4から9までの値で2空けて代入している

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?