I just started to learn python and I've comes to slices of strings.
When I type
suitcase = ["sunglasses", "hat", "passport", "laptop", "suit", "shoes"]
print suitcase[0:1]
I expect it to print ['sunglasses', 'hat]
, but I get ['sunglasses']
. From what I've read it's aList[beginIndex:endIndex]
, but from my experience it's more like aList[beginIndex:endIndex+1]
to get the index you which to have last.
Can someone explain why it's like this? I can't understand the reasoning behind it.