5. list slicing


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

I don't see whats going wrong here. seems like I did everything correct. any advice?

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)


slicing is done the following way:


but the indexes lesser then (<) the stop value are used, the stop value is not included, so [2:3] will get you the item index 2. you need index 2 and 3


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