Last active
November 26, 2021 16:50
-
-
Save yano3nora/0caf4fceb9a312456625b25040eab962 to your computer and use it in GitHub Desktop.
[python: range] #python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 から 10 までの range object 生成 | |
# | |
r = range(1, 10) | |
# range(1,10) | |
# | |
# list 変換すると、ちょっと直感的じゃないが ... | |
# 【 1 から連番を開始】して【 0 始まりだったときの 10 個目】の配列が出来る | |
# | |
list(r) | |
# [1, 2, 3, 4, 5, 6, 7, 8, 9] <= 10 までじゃないことに注意 | |
# 第二引数 stop の値はでてこない | |
# あくまでも 0 始まりから数えて stop 個目まで、なので | |
# ruby の 0..10 とかと違って直感的じゃないので使い方まじで注意 | |
# | |
r = range(1, 3+1) # 1 ~ 3 まで欲しいなーって思ったら | |
list(r) # [1, 2, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment