The slice
syntax is a handy way to refer to sub-parts of sequences – typically strings and lists. The slice s[start:end]
is the elements beginning at start and extending up to but not including end.
E.g
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
print(letters[2:5])
This will give Output : ['c', 'd', 'e']
But how does extended slicing work.
print(letters[2:4:5])
The above print statement will give ['c']
as output. I can't understand how?