・ For ruby
tmp.rb
array = [1,2,3,4,5]
array[0, 2] # => [1, 2]
array[2, 3] # => [3, 4, 5]
array[2, 1] # => [3]
array[2, 2] #=> [3, 4]
array[2, 0] # => []
・ For python
tmp.py
array = [1,2,3,4,5]
print(array[0:2]) # => [1,2]
print(array[2:3]) # => [3]
print(array[2:2]) # => []
In case of ruby, specify the number of elements with the second argument In case of python, specify the element number with the second argument