why list slices in right-to-left direction returns empty list?
I'm new to Python and was trying to understand list slicing.
This question might have been answered somewhere(I tried to look for
existing questions and their answers, but could not find what i was
looking for).
I've a list say, sample_list = [1,2,3,4,5,6,7].
Now , when I try to access:
print sample_list[-2:2]
or,
print sample_list[-3:-7]
In both cases, I get an empty list.
should not it print at-least [6,7] or [5,6,7] respectively, following
left-to-right convention?
I know, I'm doing something wrong semantic-wise.
(trying to print the list in right-to-left direction?)
I would like to understand the logic behind empty list. What is happening
here?
Thanks.
No comments:
Post a Comment