# 9. Python Lists and Dictionaries | 5. List Slicing

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

first  = suitcase[0:1]  # 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)
``````

it says the first slice only shows [“sunglasses”] when it should show ["sunglasses, “hat”] what is wrong???

``````suitcase = ["sunglasses", "hat", "passport", "laptop", "suit", "shoes"]
# The first and second items (index zero and one)
first  = suitcase[0:2]
print first
# Third and fourth items (index two and three)
middle = suitcase[2:4]
print middle
# The last two items (index four and five)
last   =    suitcase[4:6]
print last``````
4 Likes

Thank you so much!!! This really got me past a block.

1 Like

Up to but not including? This seems like a very convoluted way of pulling things from a list…

1 Like

i dont understand
The exercise says

first = suitcase[0:1] # 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)

so why you changed it to

suitcase[0:2]

middle = suitcase[2:4]

last = suitcase[4:6]

did i not understand something ?

5 Likes

Same question here. Why index zero and one is [0:2]???

1 Like

Well, ok, seems like i get it.

unlimited paint works…

1 Like

Thank you so much!!! This really got me past a block.

cheers mate!! it helped me a lot!

This is so annoying! The first parameter of a slice is the index of the first element. So why the second parameter is not the index of the last element??? That means if you want the last element to be included you have to use a non existent index number! What a stupid and confusing implementation! This makes it much more complicated and not even easier.

This should help,
suitcase = [“sunglasses”, “hat”, “passport”, “laptop”, “suit”, “shoes”]

first = suitcase[0:2]
middle = suitcase[2:4]
last = suitcase[4:6]

so easy!!! even though I got some help.