Why iloc write the end index +1?

Screen Link:
https://app.dataquest.io/c/60/m/343/data-aggregation/6/exploring-groupby-objects

My Code:

happiness2015.iloc[8:10]

Replace this line with your code

What I expected to happen:
is that should be happiness2015.iloc[8:9]

What actually happened:
why it happens like this.
happiness2015.iloc[8:10]

Replace this line with the output/error

iloc follows regular python slicing possibly because iloc is integer position based. It is end-exclusive.

So, we use 8:10 slicing to get 8 and 9.

loc, however, is different possibly because it’s label based. When using loc it’s end-inclusive. So if those were labels, then you would use 8:9 to get 8 and 9.