-2

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.

user2928929
  • 205
  • 4
  • 5
  • 8

1 Answers1

3

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]
>>>
Community
  • 1
  • 1
  • okay, and does the value of i start at, 0? or 1? – user2928929 Nov 15 '13 at 05:04
  • 1
    @user2928929 - `i` will be whatever `i` was defined as in your code. However, you are right in saying that Python indexes start at 0. –  Nov 15 '13 at 05:17