I am having trouble understanding how python labels the items in an index. This is my code:
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[4:6] # The last two items (index four and five) print(first) print(middle) print(last)
It works, but I don't get it. (I added the print part just to verify results in PyCharm.) Given that code, this is how the lists have been assigned:
sunglasses is assigned  hat is assigned  passport is also assigned  laptop is assigned  suit is also assigned  shoes is assigned 
I would have expected each of the items to have a consistent index value. What is going on?