Do not find out the problem at List Slicing


#1



https://www.codecademy.com/courses/python-beginner-en-pwmb1/1/2?curriculum_id=4f89dab3d788890003000096


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


#2

This will be a slice of only one item.


#3

ok, what is then correct if not this?


#4

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


#5

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"
why
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


#6

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?


#7

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


#8