python slice operator second element code example
Example 1: python list slice sybtax
# [start:stop:step]
# for example ...
l = [1, 2, 3, 4, 5]
l[1:4] # elements from 1 (inclusive) to 4 (exclusive)
l[2:5:2] # elements from 2 (inclusive) to 5 (exclusive) going up by 2
Example 2: python3 slice
# array[start:stop:step]
# start = include everything STARTING AT this idx (inclusive)
# stop = include everything BEFORE this idx (exclusive)
# step = (can be committed) difference between each idx in the sequence
arr = ['a', 'b', 'c', 'd', 'e']
arr[2:] => ['c', 'd', 'e']
arr[:4] => ['a', 'b', 'c', 'd']
arr[2:4] => ['c', 'd']
arr[0:5:2] => ['a', 'c', 'e']
arr[:] => makes copy of arr