Please Help


Im not sure i think im doing everything right. halp

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)


take a look at the example in the lesson.

We start at the index before the colon and continue up to but not including the index after the colon.

what does it mean?

# index no. 0    1    2    3    4 
letters = ['a', 'b', 'c', 'd', 'e']
slice1 = letters[0:2] #prints ['a', 'b'] not including the index 2
slice2 = letters[1:3] #prints ['b', 'c'] not including the index 3
slice3 = letters[2:4] #prints ['c', 'd'] not including the index 4

so in your code

middle = suitcase[2:3]

it'll only print ['passport'] but you have to print "passport" and "laptop".

same for the last


in other words, do suitcase[0:2] for first, suitcase[2:4] for middle, and suitcase[4:6] for last.


the structure is that index 0 is the first one and that shifts your whole thinking. Then on top of that, for example: suitcase[0:2] will select index 0 and 1 from suitcase and so on.


it is just a buildup from the instructions from the past lessons


i think you should give some more direct responses


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