Do not find out the problem at List Slicing


Oops, try again. It looks like your middle slice is ["passport"] instead of ["passport", "laptop"].

i expect that my coding is right

suitcase = ["sunglasses", "hat", "passport", "laptop", "suit", "shoes"]

first  = suitcase[0:2]  # The first and second items (index zero and one)
middle = suitcase[2:3]               # Third and fourth items (index two and three)
last   = suitcase[4:5]               # The last two items (index four and five)

strong text

check the image


This will be a slice of only one item.


ok, what is then correct if not this?


You want I should give you answers for something as simple as this? Come on!


haha you are so smart...

but if
suitcase[0:2] adresses to the index zero AND one
it means in this example two items "sunglasses" AND "passport"
suitcase[2:3] should adress only to one index and not both if i separate them with : in []

i'm really stucked and do not understand the reason


The first number is the first index you're including, and the second number is the index after the last one;

[0:2] #0,1
[2:3] #2
[4:5] #4

(First number is "start at this, include this", second number is "go up to this, but don't include this)

Do you understand now?


you are great, thanks for this clear and easy description, get it now