So i'm looking for sort of a layman/beginner explanation as to what this means:
L[i:i+lensub]
What does that mean by it's self? by the the way lensub = len(sublist)
and L is list.
So i'm looking for sort of a layman/beginner explanation as to what this means:
L[i:i+lensub]
What does that mean by it's self? by the the way lensub = len(sublist)
and L is list.
What that code is doing is using Explain Python's slice notation to slice L
from position i
to i+lensub
.
The format for slice notation is [start:stop:step]
.
Below is basic demonstration:
>>> lst = [1, 2, 3, 4, 5]
>>> # Get positions 1 to 3
>>> lst[1:3]
[2, 3]
>>>