Q:

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
0
# array[start:stop:step]

# start = include everything STARTING AT this idx (inclusive)
# stop = include everything BEFORE this idx (exclusive)
# step = (can be ommitted) 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
3

New to Communities?

Join the community