スライス slice

リスト,タプル,arrayなどの一部をスライスによって取り出すことができる.以下はスライスの例.この例にあるように,最初の要素を指定するために0を使ったり,最後の要素を指定するためにlenを使わない.

a[3:5]

a[:5] # a[0:5]と同じ

a[5:] # a[5:len(a)]と同じ

a[-10:] # aの最後の10要素

A part of a list, a tuple, an array, etc. can be taken out by a slice. The following is an example of a slice. As in this example, do not use 0 to specify the first element or use len to specify the last element.

a[3:5]

a[:5] # Same as a[0:5]

a[5:] # Same as a[5:len(a)]

a[-10:] # The last ten elements of a