List Slicing help!


#1

I dont know what is wrong here is my code if anyone is able to help
also I get this error"t looks like your last slice is ["laptop", "suit"] instead of ["suit", "shoes"]."

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

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


#2

last:

last   = suitcase[3:5]

are you sure that [3:5] will give you the last two items?


#3

I just fixed that and now its saying
"It looks like your middle slice is ["passport"] instead of ["passport", "laptop"]."


#4

there was nothing wrong with your middle slice? so the fix you applied, didn't fix anything


#5

yeah, I tried to fix the last slice and messed up the middle some how


#6

so you undo the change to your middle:

middle = suitcase[2:4]

and instead focus on fixing last


#7

I just fixed it by making the last slice
last = suitcase[3:6] and that worked for some reason


#8

does using last = suitcase[3:6] make sense? this will get you the last three items, not the last two items


#9

your right of course so I changed it to
last= suitcase[4:6]


#10

Do you also understand list slicing or do you have questions about it?


#11

I'm pretty sure that I understand it
Thank you!


#12