quiz question :
a=[1,2,3,4,5,6,7,8,9,10]
result for :
print a([-1:-5])
I don't know the actual output for this operation please update.
quiz question :
a=[1,2,3,4,5,6,7,8,9,10]
result for :
print a([-1:-5])
I don't know the actual output for this operation please update.
To start with, it's invalid syntax.
But even if you had your syntax correct, it's going to give you an empty array. Because it is not going to slice between -1 to -5, but it will slice between -5 to -1. Imagine that slicing will only work from a smaller number: larger number.
so
print(a[-1:-5])
will result in
[]
Whereas
print(a[-5:-1])
will result in the elements 5th position from the end of the list to the first position from the end of the list which is
[6, 7, 8, 9]