List slicing


#1



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[3:4] # The last two items (index four and five)

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

What is my mistake


Replace this line with your code.


#2

I found my mistake

in middle = suitcase [2:4]
in last = suitcase [4:6]

vote if the answer was useful for you


#3

It was helpful. I had the same exact mistake.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.