Confused with exclusive and inclusive


#1

https://www.codecademy.com/courses/python-beginner-en-KAgt5/2/1

In topic says:

Where start describes where the slice starts (inclusive), end is where it ends (exclusive)

but, if we are slice code, instance

n = [n for n in range(1, 10)]
print n
print n[2:9]

here is print:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[3, 4, 5, 6, 7, 8, 9]

where slice [2:9], and 2 is not inclusive, and 9 is not exclusive.

Where is truth?


#2

2 really is inclusive, and 9 is exclusive. the values in n[2:9] does not refer to the number in the list itself but rather the indices of those numbers.
Remember list indices start from 0 to n-1.
So in the list n

The value at index 2 is 3
the value at index 9 is 10 but it is exclusive so we get 9 instead