Michael McGill2,074 Points
what does inclusive, exclusive mean in range/slicing?
I've googled for days and tried to read stack overflow websites and I still can't get a proper answer for beginners on what inclusive and exclusive means and why. I already know that in range, the starting index is always 0, but that's not the same for stop.
This is because: start is inclusive (what is it including?)
stop is exclusive. (what is it excluding?)
ie in slicing a list: food[eggs, milk]
If both start and stop were inclusive, then the slice would be food[0, 1]
If both start and stop were exclusive, then the slice would be food[1, 2]
but it's not.
KRIS NIKOLAISEN52,654 Points
inclusive and exclusive refer to the last value: inclusive and it is included; exclusive and it is excluded. For example
1 to 10 inclusive is 1,2,3,4,5,6,7,8,9,10
1 to 10 exclusive is 1,2,3,45,6,7,8,9